# tensorplay.functional.narrow_copy Source: https://www.tensorplay.cn/docs/generated/tensorplay.functional.narrow_copy.html ```python tensorplay.functional.narrow_copy(input, dim, start, length, *, out=None) → Tensor ``` Same as Tensor.narrow() except this returns a copy rather than shared storage. This is primarily for sparse tensors, which do not have a shared-storage narrow method. Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the tensor to narrow - dim ([int](https://docs.python.org/3/builtins/functions.html#int)) – the dimension along which to narrow - start ([int](https://docs.python.org/3/builtins/functions.html#int)) – index of the element to start the narrowed dimension from. Can be negative, which means indexing from the end of dim - length ([int](https://docs.python.org/3/builtins/functions.html#int)) – length of the narrowed dimension, must be weakly positive Keyword Arguments: out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. Example: ``` >>> x = tensorplay.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> tensorplay.narrow_copy(x, 0, 0, 2) tensor([[ 1, 2, 3], [ 4, 5, 6]]) >>> tensorplay.narrow_copy(x, 1, 1, 2) tensor([[ 2, 3], [ 5, 6], [ 8, 9]]) >>> s = tensorplay.arange(16).reshape(2, 2, 2, 2).to_sparse(2) >>> tensorplay.narrow_copy(s, 0, 0, 1) tensor(indices=tensor([[0, 0], [0, 1]]), values=tensor([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]), size=(1, 2, 2, 2), nnz=2, layout=tensorplay.sparse_coo) ``` > **See also** > > tensorplay.narrow() for a non copy variant