code: def _run(  # type: ignore
      self,
      X,
      roi,
      scales=None,
      sizes=None,
      antialias=None,
      axes=None,
      coordinate_transformation_mode=None,
      cubic_coeff_a=None,
      exclude_outside=None,
      extrapolation_value=None,
      keep_aspect_ratio_policy=None,
      mode: str | None = None,
      nearest_mode=None,
  ):
      if mode == "nearest":
          if antialias:
              raise RuntimeError(
                  f"antilias={antialias!r} is not supported for mode={mode!r}."
              )
          if nearest_mode is not None:
  
              def fct(x, scale_factor):
                  del scale_factor  # unused
                  return _nearest_coeffs(x, mode=nearest_mode)
  
          else:
              fct = _nearest_coeffs
      elif mode == "cubic":
          fct_ = _cubic_coeffs_antialias if antialias else _cubic_coeffs
  
          def fct(x, scale):
              return fct_(x, scale, A=cubic_coeff_a)
  
      elif mode == "linear":
          fct = (
              _linear_coeffs_antialias if antialias else _linear_coeffs
          )
      else:
          raise ValueError(f"Unexpected value {mode!r} for mode.")
  
      if axes is None:
          output = _interpolate_nd(
              X,
              fct,
              scale_factors=scales,
              output_size=sizes,
              roi=roi,
              keep_aspect_ratio_policy=keep_aspect_ratio_policy,
              exclude_outside=exclude_outside,
              coordinate_transformation_mode=coordinate_transformation_mode,  # type: ignore
              extrapolation_value=extrapolation_value,  # type: ignore
          ).astype(X.dtype)
          return (output,)
  
      # axes is not None
      not_axes = [a for a in range(len(X.shape)) if a not in axes]
      perm = tuple(not_axes + axes)
      permuted = np.transpose(X, perm)
      new_shape = (-1, *tuple(X.shape[a] for a in axes))
      reshaped = permuted.reshape(new_shape)
      res = None
      for i in range(reshaped.shape[0]):
          output = _interpolate_nd(
              reshaped[i],
              fct,
              scale_factors=scales,
              output_size=sizes,
              roi=roi,
              keep_aspect_ratio_policy=keep_aspect_ratio_policy,
              exclude_outside=exclude_outside,
              coordinate_transformation_mode=coordinate_transformation_mode,  # type: ignore
              extrapolation_value=extrapolation_value,  # type: ignore
          ).astype(X.dtype)
          if res is None:
              res = np.empty(
                  (reshaped.shape[0], *output.shape), dtype=output.dtype
              )
          res[i] = output
  
      res_reshaped = res.reshape(tuple(X.shape[a] for a in not_axes) + res[0].shape)  # type: ignore
      new_perm = list(perm)
      for i, a in enumerate(perm):
          new_perm[a] = i
      final = np.transpose(res_reshaped, tuple(new_perm))
      return (final,)
  
file_path: onnx/onnx/reference/ops/op_resize.py
imports: from __future__ import annotations
  from typing import Any, Callable
  import numpy
  from onnx.reference.op_run import OpRun
label_desc: Use image node_id 1 for calling the Resize obj's underlying member method code with example usage: obj._run(X, roi, scales, sizes, antialias, axes, coordinate_transformation_mode, cubic_coeff_a, exclude_outside, extrapolation_value, keep_aspect_ratio_policy, mode, nearest_mode) and returns: final, output, _nearest_coeffs, fct_