code: def take(
      x: Union[int, List, torch.Tensor],
      indices: Union[int, List, torch.Tensor],
      /,
      *,
      axis: Optional[int] = None,
      mode: str = "clip",
      fill_value: Optional[Number] = None,
      out: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      if mode not in ["raise", "wrap", "clip", "fill"]:
          raise ValueError(
              "mode must be one of 'clip', 'raise', 'wrap', or 'fill'"
          )
      if not isinstance(x, torch.Tensor):
          x = torch.tensor(x)
      if len(x.shape) == 0:
          x = torch.tensor([x])
      if not isinstance(indices, torch.Tensor):
          indices = torch.tensor(indices)
      if indices.dtype.is_floating_point:
          indices = indices.to(torch.int64)
  
      # raise
      if mode == "raise":
          mode = "clip"
          if ivy.exists(axis):
              try:
                  x_shape = x.shape[axis]
              except Exception as e:
                  rank = len(x.shape)
                  raise IndexError(
                      "IndexError: Dimension out of range"
                      f"(expected to be in range of[-{rank}, {rank-1}]"
                      f", but got {axis})"
                  ) from e
          else:
              x_shape = torch.prod(torch.tensor(x.shape))
  
          bound_check = (indices < -x_shape) | (indices >= x_shape)
          if torch.any(torch.tensor(bound_check)):
              raise IndexError("index out of range in self")
  
      # clip, wrap
      if mode != "fill":
          ret = _take_with_axis(x, indices, axis=axis, mode=mode)
          if ivy.exists(out):
              ivy.inplace_update(out, ret)
          return ret
  
      # fill
      x_dtype = x.dtype
      if fill_value is None:
          # set according to jax behaviour
          # https://tinyurl.com/66jn68uj
          if x_dtype.is_floating_point or x_dtype.is_complex:
              # NaN for inexact types
              fill_value = float("NaN")
          else:
              if x_dtype == torch.bool:
                  # True for booleans
                  fill_value = True
              elif str(x_dtype).split(".")[-1].startswith("u"):
                  # the largest positive value for unsigned types
                  fill_value = torch.iinfo(x_dtype).max
              else:
                  # the largest negative value for signed types
                  fill_value = torch.iinfo(x_dtype).min
  
      fill_value = torch.tensor(fill_value, dtype=x_dtype)
      x_shape = x.shape
      ret = _take_with_axis(x, indices, axis=axis, mode="wrap")
  
      if len(ret.shape) == 0:
          # if scalar (paddle scalar), scalar fill (replace)
          if torch.any(torch.tensor(indices != 0)):
              ret = fill_value
      else:
          if ivy.exists(axis):
              rank = len(x.shape)
              axis = ((axis % rank) + rank) % rank
              x_shape = x_shape[axis]
          else:
              axis = 0
              x_shape = torch.prod(x_shape)
  
          bound_check = torch.tensor(
              (indices < -x_shape) | (indices >= x_shape)
          )
  
          if torch.any(bound_check):
              if axis > 0:
                  bound_check = torch.broadcast_to(
                      bound_check, (*x.shape[:axis], *bound_check.shape)
                  )
              ret[bound_check] = fill_value
  
      if ivy.exists(out):
          ivy.inplace_update(out, ret)
  
      return ret
  
imports: from typing import Iterable, Optional, Union, Sequence, Tuple, NamedTuple, List, Literal, Callable, Any
  from numbers import Number
  from collections import namedtuple
  import torch
  from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
  from ..None import backend_version
  import ivy
  from ivy.functional.ivy.experimental.manipulation import _to_tf_padding, _check_paddle_pad, _to_paddle_padding
label_desc: Use image node_id 28 for calling a global function with example usage: take() and returns: ret, ret