code: def preprocess(img, new=False):
      # preprocess image
      aspect_ratio = img.size[0] / img.size[1]
      img = img.resize(
          (
              int(224 * max(aspect_ratio, 1.0)),
              int(224 * max(1.0 / aspect_ratio, 1.0)),
          )
      )
  
      img = np.array(img)
      y0, x0 = (np.asarray(img.shape)[:2] - 224) // 2
      img = img[y0 : y0 + 224, x0 : x0 + 224]
  
      # low level preprocess
      if new:
          img = img.astype(np.float32)
          img -= [127.0, 127.0, 127.0]
          img /= [128.0, 128.0, 128.0]
          img = img[None]
      else:
          img = np.moveaxis(img, [2, 0, 1], [0, 1, 2])
          img = img.astype(np.float32)[:3].reshape(1, 3, 224, 224)
          img /= 255.0
          img -= np.array([0.485, 0.456, 0.406]).reshape((1, -1, 1, 1))
          img /= np.array([0.229, 0.224, 0.225]).reshape((1, -1, 1, 1))
      return img
  
imports: import ast
  import pathlib
  import unittest
  import numpy
  from PIL import Image
  from tinygrad.helpers import getenv
  from tinygrad.tensor import Tensor
  from extra.models.efficientnet import EfficientNet
  from extra.models.vit import ViT
  from extra.models.resnet import ResNet50
label_desc: Use image node_id 2 for calling a global function with example usage: preprocess(img, new) and returns: img