code: def fill_diagonal(
      a: paddle.Tensor,
      v: Union[int, float],
      /,
      *,
      wrap: bool = False,
  ) -> paddle.Tensor:
      shape = a.shape
      max_end = paddle.prod(paddle.to_tensor(shape))
      end = max_end
      if len(shape) == 2:
          step = shape[1] + 1
          if not wrap:
              end = shape[1] * shape[1]
      else:
          step = (
              1
              + (
                  paddle.cumprod(paddle.to_tensor(shape[:-1]), dim=0)
              ).sum()
          )
      end = max_end if end > max_end else end
      a = paddle.reshape(a, (-1,))
      w = paddle.zeros(a.shape, dtype=bool)
      ins = paddle.arange(0, max_end)
      steps = paddle.arange(0, end, step)
  
      for i in steps:
          i = ins == i
          w = paddle.logical_or(w, i)
      v = paddle.to_tensor(v, dtype=a.dtype)
      a = paddle.where(w, v, a)
      a = paddle.reshape(a, shape)
      return a
  
imports: from collections import namedtuple
  from typing import Iterable, Optional, Union, Sequence, Tuple, NamedTuple, List, Any, Literal, Callable
  from numbers import Number
  from ..None import backend_version
  from ivy.func_wrapper import with_supported_device_and_dtypes, with_unsupported_device_and_dtypes, with_supported_dtypes, with_unsupported_dtypes
  import paddle
  import ivy
  import ivy.functional.backends.paddle
  from ivy.functional.ivy.experimental.manipulation import _check_paddle_pad, _to_paddle_padding
label_desc: Use image node_id 24 for calling a global function with example usage: fill_diagonal() and returns: a