class_docstr: Initializer that generates the identity matrix.
  
  Constructs a 2D identity matrix or batches of these.
class_docstr_tok: ["Initializer","that","generates","the","identity","matrix",".","Constructs","a","2D","identity","matrix","or","batches","of","these","."]
code: def __call__(
      self, shape: types.ShapeLike, dtype: tf.DType
  ) -> tf.Tensor:
      dtype = _as_numerical_dtype(dtype)
      rank = (
          shape.shape[0] if isinstance(shape, tf.Tensor) else len(shape)
      )
      if rank < 2:
          raise ValueError(
              "The tensor to initialize must be "
              "at least two-dimensional"
          )
      elif rank == 2:
          initializer = tf.eye(
              num_rows=shape[0], num_columns=shape[1], dtype=dtype
          )
      else:  # rank > 2
          initializer = tf.eye(
              num_rows=shape[-2],
              num_columns=shape[-1],
              batch_shape=shape[:-2],
              dtype=dtype,
          )
      return self.gain * initializer
  
imports: import abc
  import collections
  from typing import Iterable, Mapping, Optional, Union
  import numpy
  from sonnet.src import types
  import tensorflow
label_desc: Use image node_id 2 for calling the Identity obj's underlying member method code with example usage: obj.__call__(shape, dtype) and returns: unknown