code: def tensor_diag_part(input, name=None):
      shape = ivy.shape(input, as_array=True)
      rank = len(shape)
      if rank % 2 != 0:
          raise ValueError("Wrong tensor rank, rank must be even.")
  
      rank = len(shape)
      rank_half = int(rank / 2)
      half_shape = shape[:rank_half]
      prod = 1
      for i in range(rank_half):
          if shape[i] != shape[i + rank_half]:
              raise ValueError(
                  f"Invalid shape {shape}: dimensions at {i} and {i+rank_half} do not"
                  " match."
              )
          prod *= half_shape[i]
  
      reshaped = ivy.reshape(input, (prod, prod))
      diagonal = ivy.diagonal(reshaped)
      return ivy.reshape(diagonal, tuple(half_shape))
  
imports: import ivy
  from ivy.functional.frontends.tensorflow import check_tensorflow_casting
  from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
  from ivy.functional.frontends.tensorflow.func_wrapper import to_ivy_arrays_and_back, handle_tf_dtype
  import ivy.functional.frontends.tensorflow
label_desc: Use image node_id 32 for calling a global function with example usage: tensor_diag_part(input, name) and returns: ivy