fn
take
→Tensortake(input: Tensor, indices: Tensor)Return elements of input at the given flat indices.
The input is treated as if it were flattened in row-major order; the
output has the same shape as indices. Unlike gather
there is no per-axis selection — indices address the entire tensor
as a 1-D array.
Parameters
inputTensorSource tensor.
indicesTensorInteger indices into the flattened input.
Returns
TensorTensor of the same shape as indices.
Notes
Useful for sparse lookups when the index pattern does not align with a single axis.
Examples
>>> import lucid
>>> x = lucid.tensor([[1, 2], [3, 4]])
>>> lucid.take(x, lucid.tensor([0, 3]))
Tensor([1, 4])