code: def interpolate(
      input: JaxArray,
      size: Union[int, Tuple[int, ...]] = None,
      scale_factor: Union[int, Tuple[int, ...]] = None,
      mode: Union[Interpolate, str] = Interpolate.BILINEAR,
  ) -> JaxArray:
      """
      Function to interpolate JaxArrays by size or scaling factor
      Args:
          input: input tensor
          size: int or tuple for output size
          scale_factor: int or tuple scaling factor for each dimention
          mode:str or Interpolate interpolation method e.g. ['bilinear', 'nearest']
  
      Returns:
          output : output JaxArray after interpolation
      """
      assert (
          size or scale_factor
      ), f"both size: {size} and scale_factor: {scale_factor} can not be None ."
      assert bool(size) ^ bool(scale_factor), (
          f"either size or scale_factor must be none "
          f"scale: {size}, scale_factor: {scale_factor} ."
      )
      input_shape = input.shape
      input_dim = len(input_shape)
      if scale_factor:
          if isinstance(scale_factor, int):
              size = (
                  input_shape[0],
                  *(jn.array(input_shape[1:]) * scale_factor),
              )
          if isinstance(scale_factor, Tuple):
              output_dim = len(scale_factor)
              size = (
                  *input_shape[: input_dim - output_dim],
                  *(
                      jn.array(input_shape[input_dim - output_dim :])
                      * jn.array(scale_factor)
                  ),
              )
      else:
          if isinstance(size, int):
              size = (*input_shape[:-1], size)
          if isinstance(size, Tuple):
              output_dim = len(size)
              assert input_dim >= output_dim, (
                  f'Number of dimensions of "{size}"'
                  f' must be < = to input shape"{input_shape}" '
              )
              size = (*input_shape[: input_dim - output_dim], *size)
      output = jax.image.resize(
          input, shape=size, method=util.to_interpolate(mode)
      )
      return output
  
file_path: objax/objax/functional/core/ops.py
imports: from typing import Union, Tuple
  import jax.nn
  from jax import numpy, lax
  from objax import util
  from objax.constants import Interpolate
  from objax.typing import JaxArray
label_desc: Use image node_id 2 for calling a global function with example usage: interpolate(input, size, scale_factor, mode) and returns: output