code: def transform_fn(
      model, payload, request_content_type, response_content_type
  ):
      logger.info("Invoking user-defined transform function")
  
      if request_content_type != "application/octet-stream":
          raise RuntimeError(
              "Content type must be application/octet-stream. Provided: {0}".format(
                  request_content_type
              )
          )
  
      # preprocess image
      decoded = Image.open(io.BytesIO(payload))
      preprocess = transforms.Compose(
          [
              transforms.Resize(256),
              transforms.CenterCrop(224),
              transforms.ToTensor(),
              transforms.Normalize(
                  mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]
              ),
          ]
      )
      normalized = preprocess(decoded)
      batchified = normalized.unsqueeze(0)
  
      # predict
      device = torch.device(
          "cuda" if torch.cuda.is_available() else "cpu"
      )
      batchified = batchified.to(device)
      result = model.forward(batchified)
  
      # Softmax (assumes batch size 1)
      result = np.squeeze(result.cpu().numpy())
      result_exp = np.exp(result - np.max(result))
      result = result_exp / np.sum(result_exp)
  
      response_body = json.dumps(result.tolist())
      content_type = "application/json"
  
      return response_body, content_type
  
file_path: sagemaker-python-sdk/tests/data/pytorch_neo/code/inference.py
imports: import io
  import json
  import logging
  import os
  import pickle
  import numpy
  import torch
  import neopytorch
  import torchvision.transforms
  from PIL import Image
label_desc: Use image node_id 1 for calling a global function with example usage: transform_fn(model, payload, request_content_type, response_content_type) and returns: response_body,  content_type