code: def _scale_and_translate(
      x,
      output_shape: core.Shape,
      spatial_dims: Sequence[int],
      scale,
      translation,
      kernel,
      antialias: bool,
      precision,
  ):
      input_shape = x.shape
      assert len(input_shape) == len(output_shape)
      assert len(spatial_dims) == len(scale)
      assert len(spatial_dims) == len(translation)
      if len(spatial_dims) == 0:
          return x
      contractions = []
      in_indices = list(range(len(output_shape)))
      out_indices = list(range(len(output_shape)))
      for i, d in enumerate(spatial_dims):
          d = canonicalize_axis(d, x.ndim)
          m = input_shape[d]
          n = output_shape[d]
          w = compute_weight_mat(
              m, n, scale[i], translation[i], kernel, antialias
          ).astype(x.dtype)
          contractions.append(w)
          contractions.append([d, len(output_shape) + i])
          out_indices[d] = len(output_shape) + i
      contractions.append(out_indices)
      return jnp.einsum(
          x, in_indices, *contractions, precision=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 5 for calling a global function with example usage: _scale_and_translate(x, output_shape, spatial_dims, scale, translation, kernel, antialias, precision) and returns: jnp, x