combinations(input: Tensor, r: int = 2, with_replacement: bool = False)All r-length combinations of the elements of a 1-D input.
The positions of every combination are built on the CPU, then read
from input with one index_select — differentiable through
input, and on its device.
Parameters
inputTensor1-D source tensor of length . Raises on higher rank.
rint= 2Combination length. Default
2.with_replacementbool= FalseWhen
True the output enumerates multisets (an element can
appear multiple times in a single row), giving
rows. Default False (strict
combinations, rows).Returns
TensorShape (C, r) where is the combination count, in
lexicographic order of positions; shape (0,) when r is 0.
Dtype and device follow input.
Raises
ValueErrorinput is not 1-D, or r is negative.Examples
>>> import lucid
>>> lucid.combinations(lucid.tensor([1, 2, 3]), r=2)
tensor([[1, 2], [1, 3], [2, 3]], dtype=lucid.int64)