code: def diagflat(
      x: Union[tf.Tensor, tf.Variable],
      /,
      *,
      offset: int = 0,
      padding_value: float = 0,
      align: str = "RIGHT_LEFT",
      num_rows: Optional[int] = None,
      num_cols: Optional[int] = None,
      out: Optional[Union[tf.Tensor, tf.Variable]] = None,
  ):
      if len(x.shape) > 1:
          x = tf.reshape(x, [-1])
  
      if num_rows is None:
          num_rows = -1
      if num_cols is None:
          num_cols = -1
  
      ret = tf.linalg.diag(
          x,
          name="diagflat",
          k=offset,
          num_rows=num_rows,
          num_cols=num_cols,
          padding_value=padding_value,
          align=align,
      )
  
      if ivy.exists(out):
          ivy.inplace_update(out, ret)
  
      return ret
  
file_path: ivy/ivy/functional/backends/tensorflow/experimental/linear_algebra.py
imports: from typing import Union, Optional, Tuple, List, Sequence
  import tensorflow
  from functools import reduce
  import ivy
  from ivy.functional.ivy.experimental.linear_algebra import _check_valid_dimension_size
  from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
  from ivy.utils.exceptions import IvyNotImplementedException
  from ..None import backend_version
label_desc: Use image node_id 2 for calling a global function with example usage: diagflat() and returns: ret