code: def take_along_axis(
      arr: np.ndarray,
      indices: np.ndarray,
      axis: int,
      /,
      *,
      mode: str = "fill",
      out: Optional[np.ndarray] = None,
  ) -> np.ndarray:
      if arr.ndim != indices.ndim:
          raise ivy.utils.exceptions.IvyException(
              "arr and indices must have the same number of dimensions;"
              + f" got {arr.ndim} vs {indices.ndim}"
          )
      if mode not in ["clip", "fill", "drop"]:
          raise ValueError(
              f"Invalid mode '{mode}'. Valid modes are 'clip', 'fill', 'drop'."
          )
      arr_shape = arr.shape
      if axis < 0:
          axis += arr.ndim
      if mode == "clip":
          max_index = arr.shape[axis] - 1
          indices = np.clip(indices, 0, max_index)
      elif mode in ("fill", "drop"):
          if "float" in str(arr.dtype) or "complex" in str(arr.dtype):
              fill_value = np.NAN
          elif "uint" in str(arr.dtype):
              fill_value = np.iinfo(arr.dtype).max
          elif "int" in str(arr.dtype):
              fill_value = -np.iinfo(arr.dtype).max - 1
          else:
              raise TypeError(
                  f"Invalid dtype '{arr.dtype}'. Valid dtypes are 'float', 'complex',"
                  " 'uint', 'int'."
              )
          indices = np.where(
              (indices < 0) | (indices >= arr.shape[axis]), -1, indices
          )
          arr_shape = list(arr_shape)
          arr_shape[axis] = 1
          fill_arr = np.full(arr_shape, fill_value, dtype=arr.dtype)
          arr = np.concatenate([arr, fill_arr], axis=axis)
      return np.take_along_axis(arr, indices, axis)
  
imports: from typing import Iterable, Optional, Union, Sequence, Tuple, NamedTuple, Literal, Callable, Any, List
  from numbers import Number
  from collections import namedtuple
  import numpy
  import ivy
  from ivy.functional.backends.numpy.helpers import _scalar_output_to_0d_array
  from ivy.func_wrapper import with_supported_dtypes
  from .None import backend_version
label_desc: Use image node_id 20 for calling a global function with example usage: take_along_axis() and returns: np