torchoutil.types.tensor_subclasses module

Tensor subclasses for typing and instance checks.

Note: torchoutil.FloatTensor != torch.FloatTensor but issubclass(torchoutil.FloatTensor, torch.FloatTensor) is False because torch.FloatTensor cannot be subclassed

Here is an overview of the valid tensor subclasses tree:
Tensor

ComplexFloatingTensor FloatingTensor IntegralTensor
| |

+————+————+ +———–+———–+ +——————+——————+ | | | | | | | |

CHalfTensor CFloatTensor CDoubleTensor HalfTensor FloatTensor DoubleTensor SignedIntegerTensor UnsignedIntegerTensor
(c32) (c64) (c128) (f16) (f32) (f64) | |

+———–+—–+—–+———–+ +—–+—–+ | | | | | |

CharTensor ShortTensor IntTensor LongTensor ByteTensor BoolTensor

(i8) (i16) (i32) (i64) (u8) (bool)

class BoolTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class BoolTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.bool: ‘bool’>], int, bool, Literal[0], Literal[0], Literal[0]]

class BoolTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class BoolTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.bool: ‘bool’>], Literal[0], bool, Literal[0], Literal[0], Literal[0]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class BoolTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class BoolTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.bool: ‘bool’>], Literal[1], bool, Literal[0], Literal[0], Literal[0]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class BoolTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class BoolTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.bool: ‘bool’>], Literal[2], bool, Literal[0], Literal[0], Literal[0]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class BoolTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class BoolTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.bool: ‘bool’>], Literal[3], bool, Literal[0], Literal[0], Literal[0]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class ByteTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ByteTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.uint8: ‘uint8’>], int, int, Literal[0], Literal[0], Literal[0]]

class ByteTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ByteTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.uint8: ‘uint8’>], Literal[0], int, Literal[0], Literal[0], Literal[0]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class ByteTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ByteTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.uint8: ‘uint8’>], Literal[1], int, Literal[0], Literal[0], Literal[0]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class ByteTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ByteTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.uint8: ‘uint8’>], Literal[2], int, Literal[0], Literal[0], Literal[0]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class ByteTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ByteTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.uint8: ‘uint8’>], Literal[3], int, Literal[0], Literal[0], Literal[0]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CDoubleTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CDoubleTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex128: ‘complex128’>], int, complex, Literal[0], Literal[1], Literal[1]]

class CDoubleTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CDoubleTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex128: ‘complex128’>], Literal[0], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CDoubleTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CDoubleTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex128: ‘complex128’>], Literal[1], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CDoubleTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CDoubleTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex128: ‘complex128’>], Literal[2], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CDoubleTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CDoubleTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex128: ‘complex128’>], Literal[3], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CFloatTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CFloatTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex64: ‘complex64’>], int, complex, Literal[0], Literal[1], Literal[1]]

class CFloatTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CFloatTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex64: ‘complex64’>], Literal[0], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CFloatTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CFloatTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex64: ‘complex64’>], Literal[1], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CFloatTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CFloatTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex64: ‘complex64’>], Literal[2], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CFloatTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CFloatTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex64: ‘complex64’>], Literal[3], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CHalfTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CHalfTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex32: ‘complex32’>], int, complex, Literal[0], Literal[1], Literal[1]]

class CHalfTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CHalfTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex32: ‘complex32’>], Literal[0], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CHalfTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CHalfTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex32: ‘complex32’>], Literal[1], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CHalfTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CHalfTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex32: ‘complex32’>], Literal[2], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CHalfTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CHalfTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.complex32: ‘complex32’>], Literal[3], complex, Literal[0], Literal[1], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CharTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CharTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int8: ‘int8’>], int, int, Literal[0], Literal[0], Literal[1]]

class CharTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CharTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int8: ‘int8’>], Literal[0], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CharTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CharTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int8: ‘int8’>], Literal[1], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CharTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CharTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int8: ‘int8’>], Literal[2], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class CharTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class CharTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int8: ‘int8’>], Literal[3], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class ComplexFloatingTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ComplexFloatingTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], int, complex, Literal[0], Literal[1], Literal[1]]

Intermediate class for checking and typing complex-valued tensors. - Concrete subclasses are: CFloatTensor, CHalfTensor, CDoubleTensor. - Properties are: is_floating_point=False, is_complex=True, is_signed=True. - By default, instantiate this class will create a CFloatTensor.

class ComplexFloatingTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ComplexFloatingTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[0], complex, Literal[0], Literal[1], Literal[1]]

class ComplexFloatingTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ComplexFloatingTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[1], complex, Literal[0], Literal[1], Literal[1]]

class ComplexFloatingTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ComplexFloatingTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[2], complex, Literal[0], Literal[1], Literal[1]]

class ComplexFloatingTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ComplexFloatingTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[3], complex, Literal[0], Literal[1], Literal[1]]

class DoubleTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class DoubleTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float64: ‘float64’>], int, float, Literal[1], Literal[0], Literal[1]]

class DoubleTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class DoubleTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float64: ‘float64’>], Literal[0], float, Literal[1], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class DoubleTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class DoubleTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float64: ‘float64’>], Literal[1], float, Literal[1], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class DoubleTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class DoubleTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float64: ‘float64’>], Literal[2], float, Literal[1], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class DoubleTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class DoubleTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float64: ‘float64’>], Literal[3], float, Literal[1], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class FloatTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class FloatTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float32: ‘float32’>], int, float, Literal[1], Literal[0], Literal[1]]

class FloatTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class FloatTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float32: ‘float32’>], Literal[0], float, Literal[1], Literal[0], Literal[1]]

class FloatTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class FloatTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float32: ‘float32’>], Literal[1], float, Literal[1], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class FloatTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class FloatTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float32: ‘float32’>], Literal[2], float, Literal[1], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class FloatTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class FloatTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float32: ‘float32’>], Literal[3], float, Literal[1], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class FloatingTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class FloatingTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], int, float, Literal[1], Literal[0], Literal[1]]

Intermediate class for checking and typing floating-point tensors. - Concrete subclasses are: FloatTensor, HalfTensor, DoubleTensor. - Properties are: is_floating_point=True, is_complex=False, is_signed=True. - By default, instantiate this class will create a FloatTensor.

class FloatingTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class FloatingTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[0], float, Literal[1], Literal[0], Literal[1]]

class FloatingTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class FloatingTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[1], float, Literal[1], Literal[0], Literal[1]]

class FloatingTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class FloatingTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[2], float, Literal[1], Literal[0], Literal[1]]

class FloatingTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class FloatingTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[3], float, Literal[1], Literal[0], Literal[1]]

class HalfTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class HalfTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float16: ‘float16’>], int, float, Literal[1], Literal[0], Literal[1]]

class HalfTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class HalfTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float16: ‘float16’>], Literal[0], float, Literal[1], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class HalfTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class HalfTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float16: ‘float16’>], Literal[1], float, Literal[1], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class HalfTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class HalfTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float16: ‘float16’>], Literal[2], float, Literal[1], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class HalfTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class HalfTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.float16: ‘float16’>], Literal[3], float, Literal[1], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class IntTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class IntTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int32: ‘int32’>], int, int, Literal[0], Literal[0], Literal[1]]

class IntTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class IntTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int32: ‘int32’>], Literal[0], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class IntTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class IntTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int32: ‘int32’>], Literal[1], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class IntTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class IntTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int32: ‘int32’>], Literal[2], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class IntTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class IntTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int32: ‘int32’>], Literal[3], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class IntegralTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class IntegralTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], int, int, Literal[0], Literal[0], bool]

Intermediate class for checking and typing integer data type (integer-like) tensors. - Concrete subclasses are: CharTensor, ShortTensor, IntTensor, LongTensor, BoolTensor, ByteTensor. - Properties are: is_floating_point=False, is_complex=False. - By default, instantiate this class will create an LongTensor. - BoolTensor is a subclass of UnsignedIntegerTensor.

class IntegralTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class IntegralTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[0], int, Literal[0], Literal[0], bool]

class IntegralTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class IntegralTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[1], int, Literal[0], Literal[0], bool]

class IntegralTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class IntegralTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[2], int, Literal[0], Literal[0], bool]

class IntegralTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class IntegralTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[3], int, Literal[0], Literal[0], bool]

class LongTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class LongTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int64: ‘int64’>], int, int, Literal[0], Literal[0], Literal[1]]

class LongTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class LongTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int64: ‘int64’>], Literal[0], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class LongTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class LongTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int64: ‘int64’>], Literal[1], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class LongTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class LongTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int64: ‘int64’>], Literal[2], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class LongTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class LongTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int64: ‘int64’>], Literal[3], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class ShortTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ShortTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int16: ‘int16’>], int, int, Literal[0], Literal[0], Literal[1]]

class ShortTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ShortTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int16: ‘int16’>], Literal[0], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class ShortTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ShortTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int16: ‘int16’>], Literal[1], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class ShortTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ShortTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int16: ‘int16’>], Literal[2], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class ShortTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class ShortTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[<DTypeEnum.int16: ‘int16’>], Literal[3], int, Literal[0], Literal[0], Literal[1]]

tolist() list or number[source]

Returns the tensor as a (nested) list. For scalars, a standard Python number is returned, just like with item(). Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>> a = torch.randn(2, 2)
>>> a.tolist()
[[0.012766935862600803, 0.5415473580360413],
 [-0.08909505605697632, 0.7729271650314331]]
>>> a[0,0].tolist()
0.012766935862600803
class SignedIntegerTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class SignedIntegerTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], int, int, Literal[0], Literal[0], Literal[1]]

Intermediate class for checking and typing signed integer data type (integer-like) tensors. - Concrete subclasses are: IntTensor, LongTensor, ShortTensor. - Properties are: is_floating_point=False, is_complex=False, is_signed=True. - By default, instantiate this class will create an IntTensor. - BoolTensor is not a subclass of SignedIntegerTensor because it is not signed.

class SignedIntegerTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class SignedIntegerTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[0], int, Literal[0], Literal[0], Literal[1]]

class SignedIntegerTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class SignedIntegerTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[1], int, Literal[0], Literal[0], Literal[1]]

class SignedIntegerTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class SignedIntegerTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[2], int, Literal[0], Literal[0], Literal[1]]

class SignedIntegerTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class SignedIntegerTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[3], int, Literal[0], Literal[0], Literal[1]]

class Tensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class Tensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], int, Union[bool, int, float, complex], bool, bool, bool]

class Tensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class Tensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[0], Union[bool, int, float, complex], bool, bool, bool]

class Tensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class Tensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[1], Union[bool, int, float, complex], bool, bool, bool]

class Tensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class Tensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[2], Union[bool, int, float, complex], bool, bool, bool]

class Tensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class Tensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[3], Union[bool, int, float, complex], bool, bool, bool]

class UnsignedIntegerTensor(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class UnsignedIntegerTensor(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], int, int, Literal[0], Literal[0], Literal[0]]

Intermediate class for checking and typing unsigned integer data type (integer-like) tensors. - Concrete subclasses are: BoolTensor, ByteTensor. - Properties are: is_floating_point=False, is_complex=False, is_signed=False. - By default, instantiate this class will create an ByteTensor. - BoolTensor is a subclass of UnsignedIntegerTensor.

class UnsignedIntegerTensor0D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class UnsignedIntegerTensor0D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[0], int, Literal[0], Literal[0], Literal[0]]

class UnsignedIntegerTensor1D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class UnsignedIntegerTensor1D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[1], int, Literal[0], Literal[0], Literal[0]]

class UnsignedIntegerTensor2D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class UnsignedIntegerTensor2D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[2], int, Literal[0], Literal[0], Literal[0]]

class UnsignedIntegerTensor3D(
*dims: int,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
memory_format: memory_format | None = None,
out: Tensor | None = None,
layout: layout | None = None,
pin_memory: bool | None = False,
requires_grad: bool | None = False,
)[source]
class UnsignedIntegerTensor3D(
data: T_BuiltinNumber | Sequence,
/,
*,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
)

Bases: _TensorNDBase[Literal[None], Literal[3], int, Literal[0], Literal[0], Literal[0]]