code: def rescale_numpy(
      x: ep.NumPyTensor, target_shape: List[int]
  ) -> ep.NumPyTensor:
      import numpy as np
  
      img = x.raw
  
      resize_rates = (
          target_shape[1] / x.shape[1],
          target_shape[2] / x.shape[2],
      )
  
      def interpolate_bilinear(
          im: np.ndarray, rows: np.ndarray, cols: np.ndarray
      ) -> np.ndarray:
          # based on http://stackoverflow.com/a/12729229
          col_lo = np.floor(cols).astype(int)
          col_hi = col_lo + 1
          row_lo = np.floor(rows).astype(int)
          row_hi = row_lo + 1
  
          def cclip(cols: np.ndarray) -> np.ndarray:
              return np.clip(cols, 0, ncols - 1)
  
          def rclip(rows: np.ndarray) -> np.ndarray:
              return np.clip(rows, 0, nrows - 1)
  
          nrows, ncols = im.shape[-3:-1]
  
          Ia = im[..., rclip(row_lo), cclip(col_lo), :]
          Ib = im[..., rclip(row_hi), cclip(col_lo), :]
          Ic = im[..., rclip(row_lo), cclip(col_hi), :]
          Id = im[..., rclip(row_hi), cclip(col_hi), :]
  
          wa = np.expand_dims((col_hi - cols) * (row_hi - rows), -1)
          wb = np.expand_dims((col_hi - cols) * (rows - row_lo), -1)
          wc = np.expand_dims((cols - col_lo) * (row_hi - rows), -1)
          wd = np.expand_dims((cols - col_lo) * (rows - row_lo), -1)
  
          return wa * Ia + wb * Ib + wc * Ic + wd * Id  # type: ignore
  
      nrows, ncols = img.shape[-3:-1]
      deltas = (0.5 / resize_rates[0], 0.5 / resize_rates[1])
  
      rows = np.linspace(
          deltas[0],
          nrows - deltas[0],
          np.int32(resize_rates[0] * nrows),
      )
      cols = np.linspace(
          deltas[1],
          ncols - deltas[1],
          np.int32(resize_rates[1] * ncols),
      )
      rows_grid, cols_grid = np.meshgrid(
          rows - 0.5, cols - 0.5, indexing="ij"
      )
  
      img_resize_vec = interpolate_bilinear(
          img, rows_grid.flatten(), cols_grid.flatten()
      )
      img_resize = img_resize_vec.reshape(
          img.shape[:-3] + (len(rows), len(cols)) + img.shape[-1:]
      )
  
      return ep.NumPyTensor(img_resize)
  
imports: from typing import Union, List, Tuple
  import eagerpy
label_desc: Use image node_id 2 for calling a global function with example usage: rescale_numpy(x, target_shape) and returns: ep, unknown, np, np