def resize(image: jnp.ndarray, shape: core.Shape):
  """Simplified utility for resizing, matching Chainer's aligned corner resizing."""
  shape = core.canonicalize_shape(shape)
  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 not jnp.issubdtype(image.dtype, jnp.inexact):
    image = lax.convert_element_type(image, jnp.result_type(image, jnp.float32))
  # 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.symbolic_equal_dim(image.shape[i], shape[i]))
  scale = [(core.dimension_as_value(shape[d]) - 1) /
           (core.dimension_as_value(image.shape[d]) - 1) for d in spatial_dims]
  return _scale(image, shape, spatial_dims, scale)
Simplified utility for resizing, matching Chainer's aligned corner resizing.
videogvt/train_lib/inception_score.py