code: def tensor_diag(diagonal, /, *, name=None):
      diagonal = ivy.array(diagonal)
      rank = ivy.matrix_rank(diagonal)
      if rank > 1:
          raise ValueError("wrong tensor rank, at most 1")
      return ivy.diag(diagonal)
  
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 31 for calling a global function with example usage: tensor_diag() and returns: ivy