code: def gradient(
      x: torch.Tensor,
      /,
      *,
      spacing: Union[int, list, tuple] = 1,
      axis: Optional[Union[int, list, tuple]] = None,
      edge_order: int = 1,
  ) -> Union[torch.Tensor, List[torch.Tensor]]:
      if axis is None:
          axis = tuple(range(len(x.shape)))
      if isinstance(axis, int):
          axis = (axis,)
      if isinstance(spacing, int):
          spacing = [spacing] * len(axis)
  
      grad = torch.gradient(
          x, spacing=spacing, dim=axis, edge_order=edge_order
      )
      if len(grad) == 1:
          return grad[0]
      return grad
  
imports: from typing import Optional, Union, Tuple, List, Sequence
  from numbers import Number
  import torch
  import ivy
  from ivy import promote_types_of_inputs
  from ivy.functional.backends.torch.elementwise import _cast_for_unary_op
  from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
  from ..None import backend_version
label_desc: Use image node_id 18 for calling a global function with example usage: gradient() and returns: grad, grad