code: def _resize(
      image,
      shape: core.Shape,
      method: str | ResizeMethod,
      antialias: bool,
      precision,
  ):
      if len(shape) != image.ndim:
          msg = (
              "shape must have length equal to the number of dimensions of x; "
              f" {shape} vs {image.shape}"
          )
          raise ValueError(msg)
      if isinstance(method, str):
          method = ResizeMethod.from_string(method)
      if method == ResizeMethod.NEAREST:
          return _resize_nearest(image, shape)
      assert isinstance(method, ResizeMethod)
      kernel = _kernels[method]
  
      (image,) = promote_dtypes_inexact(image)
      # Skip dimensions that have scale=1 and translation=0, this is only possible
      # since all of the current resize methods (kernels) are interpolating, so the
      # output = input under an identity warp.
      spatial_dims = tuple(
          i
          for i in range(len(shape))
          if not core.definitely_equal(image.shape[i], shape[i])
      )
      scale = [
          1.0
          if core.definitely_equal(shape[d], 0)
          else core.dimension_as_value(shape[d])
          / core.dimension_as_value(image.shape[d])
          for d in spatial_dims
      ]
      return _scale_and_translate(
          image,
          shape,
          spatial_dims,
          scale,
          [0.0] * len(spatial_dims),
          kernel,
          antialias,
          precision,
      )
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  from functools import partial
  import enum
  from typing import Callable
  import numpy
  from jax import jit
  from jax import lax
  from jax import numpy
  from jax._src import core
  from jax._src.util import canonicalize_axis
  from jax._src.numpy.util import promote_dtypes_inexact
label_desc: Use image node_id 8 for calling a global function with example usage: _resize(image, shape, method, antialias, precision) and returns: _scale_and_translate, _resize_nearest