code: def eye_like(
      x: Union[ivy.Array, ivy.NativeArray],
      *,
      k: int = 0,
      dtype: Optional[Union[ivy.Dtype, ivy.NativeDtype]] = None,
      device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
      out: Optional[ivy.Array] = None,
  ) -> ivy.Array:
      """Return a 2D array filled with ones on the k diagonal and zeros
      elsewhere. having the same ``shape`` as the first and last dim of input
      array ``x``. input array ``x`` should to be 2D.
  
      Parameters
      ----------
      x
           input array from which to derive the output array shape.
      k
          index of the diagonal. A positive value refers to an upper diagonal, a negative
          value to a lower diagonal, and 0 to the main diagonal. Default: ``0``.
      dtype
          output array data type. If dtype is None, the output array data type must be the
          default floating-point data type. Default: ``None``.
      device
          the device on which to place the created array.
      out
          optional output array, for writing the result to. It must have a shape that the
          inputs broadcast to.
  
      Returns
      -------
      ret
          an array having the same shape as ``x`` and filled with ``ones`` in
          diagonal ``k`` and ``zeros`` elsewhere.
  
  
      Both the description and the type hints above assumes an array input for simplicity,
      but this function is *nestable*, and therefore also accepts :class:`ivy.Container`
      instances as a replacement to any of the arguments.
  
      Examples
      --------
      With :class:`ivy.Array` input:
  
      >>> x1 = ivy.array([[0, 1],[2, 3]])
      >>> y1 = ivy.eye_like(x1)
      >>> print(y1)
      ivy.array([[1., 0.],
                 [0., 1.]])
  
      >>> x1 = ivy.array([[0, 1, 2],[3, 4, 5],[6, 7, 8]])
      >>> y1 = ivy.eye_like(x1, k=1)
      >>> print(y1)
      ivy.array([[0., 1., 0.],
                 [0., 0., 1.],
                 [0., 0., 0.]])
  
      With :class:`ivy.Container` input:
  
      >>> x = ivy.Container(a=ivy.array([[3, 8],[0, 2]]), b=ivy.array([[0, 2], [8, 5]]))
      >>> y = x.eye_like()
      >>> print(y)
      {
          a: ivy.array([[1., 0.],
                        [0., 1.]]),
          b: ivy.array([[1., 0.],
                        [0., 1.]])
      }
      """
      shape = ivy.shape(x, as_array=True)
      dim = len(shape)
      if dim <= 1:
          cols = dim
      else:
          cols = int(shape[-1])
      rows = 0 if dim < 1 else int(shape[0])
      return ivy.eye(
          rows,
          cols,
          k=k,
          dtype=dtype,
          device=device,
          out=out,
      )
  
imports: from typing import Union, Tuple, Optional, Sequence, Iterable, Generator
  import warnings
  import ivy
  from ivy.utils.backend import current_backend
  from ivy.utils.exceptions import handle_exceptions
  from ivy.func_wrapper import outputs_to_ivy_arrays, handle_nestable, to_native_arrays_and_back, handle_out_argument, infer_dtype, handle_array_like_without_promotion, inputs_to_ivy_arrays, handle_device, handle_backend_invalid, handle_array_function
label_desc: Use image node_id 7 for calling a global function with example usage: eye_like(x) and returns: ivy