code: def diag(x, offset=0, padding_value=0, name=None):
      if len(x.shape) == 1:
          padding_value = ivy.astype(padding_value, ivy.dtype(x))
          ret = ivy.diagflat(
              x, offset=offset, padding_value=padding_value
          )
          if len(ret.shape) != 2:
              ret = ivy.reshape(ret, (1, 1))
      else:
          ret = ivy.diag(x, k=offset)
      return ret
  
imports: import ivy
  from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
  import ivy.functional.frontends.paddle
  from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
label_desc: Use image node_id 5 for calling a global function with example usage: diag(x, offset, padding_value, name) and returns: ret