torch.narrow_copy
function narrow_copy(input: Tensor, dim: number, start: number, length: number): voidReturns a copy of a narrowed version of the input tensor along a dimension. Unlike narrow(), this returns a copy rather than a view with shared storage.
Parameters
inputTensor- The input tensor
dimnumber- Dimension along which to narrow
startnumber- Starting index
lengthnumber- Length of the narrowed dimension
Returns
A copy of the narrowed tensor
Examples
const x = torch.arange(12).reshape(3, 4);
const y = torch.narrow_copy(x, 0, 0, 2); // Copy of first 2 rows