code: def rescale_images(
      x: ep.TensorType,
      target_shape: Union[Tuple[int, ...], List[int]],
      channel_axis: int,
  ) -> ep.TensorType:
      target_shape = list(target_shape)
  
      if channel_axis < 0:
          channel_axis = x.ndim - 1 + channel_axis
  
      if isinstance(x, ep.PyTorchTensor):
          if channel_axis != 1:
              x = swap_axes(x, channel_axis, 1)  # type: ignore
  
              target_shape[channel_axis], target_shape[1] = (
                  target_shape[1],
                  target_shape[channel_axis],
              )
  
          x = rescale_pytorch(x, target_shape)  # type: ignore
  
          if channel_axis != 1:
              x = swap_axes(x, channel_axis, 1)  # type: ignore
  
      elif isinstance(x, ep.TensorFlowTensor):
          if channel_axis != x.ndim - 1:
              x = swap_axes(x, channel_axis, x.ndim - 1)  # type: ignore
  
              target_shape[channel_axis], target_shape[x.ndim - 1] = (
                  target_shape[x.ndim - 1],
                  target_shape[channel_axis],
              )
  
          x = rescale_tensorflow(x, target_shape)  # type: ignore
  
          if channel_axis != x.ndim - 1:
              x = swap_axes(x, channel_axis, x.ndim - 1)  # type: ignore
  
      elif isinstance(x, ep.NumPyTensor):
          if channel_axis != x.ndim - 1:
              x = swap_axes(x, channel_axis, x.ndim - 1)  # type: ignore
  
              target_shape[channel_axis], target_shape[x.ndim - 1] = (
                  target_shape[x.ndim - 1],
                  target_shape[channel_axis],
              )
  
          x = rescale_numpy(x, target_shape)  # type: ignore
          if channel_axis != x.ndim - 1:
              x = swap_axes(x, channel_axis, x.ndim - 1)  # type: ignore
  
      elif isinstance(x, ep.JAXTensor):
          if channel_axis != x.ndim - 1:
              x = swap_axes(x, channel_axis, x.ndim - 1)  # type: ignore
  
              target_shape[channel_axis], target_shape[x.ndim - 1] = (
                  target_shape[x.ndim - 1],
                  target_shape[channel_axis],
              )
  
          x = rescale_jax(x, target_shape)  # type: ignore
          if channel_axis != x.ndim - 1:
              x = swap_axes(x, channel_axis, x.ndim - 1)  # type: ignore
  
      return x
  
imports: from typing import Union, List, Tuple
  import eagerpy
label_desc: Use image node_id 6 for calling a global function with example usage: rescale_images(x, target_shape, channel_axis) and returns: x