# tensorplay.functional.eye Source: https://www.tensorplay.cn/docs/generated/tensorplay.functional.eye.html ```python tensorplay.functional.eye(n, m=None, *, out=None, dtype=None, layout=tensorplay.strided, device=None, requires_grad=False) → Tensor ``` Returns a 2-D tensor with ones on the diagonal and zeros elsewhere. Parameters: - n ([int](https://docs.python.org/3/builtins/functions.html#int)) – the number of rows - m ([int](https://docs.python.org/3/builtins/functions.html#int), optional) – the number of columns with default being n Keyword Arguments: - out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of returned tensor. Default: if None, uses a global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout (tensorplay.layout, optional) – the desired layout of returned Tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If autograd should record operations on the returned tensor. Default: False. Returns: A 2-D tensor with ones on the diagonal and zeros elsewhere Return type: [Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor) Example: ``` >>> tensorplay.eye(3) tensor([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]]) ```