code: def preprocess(self, data):
      images = []
      for row in data:
          imgs = row.get("data") or row.get("body")
          imgs = list(imgs.values())
          for image in imgs:
              if isinstance(image, str):
                  # if the image is a string of bytesarray.
                  image = base64.b64decode(image)
  
              # If the image is sent as bytesarray
              if isinstance(image, (bytearray, bytes)):
                  image = Image.open(io.BytesIO(image))
                  image = self.image_processing(image)
              else:
                  # if the image is a list
                  image = torch.FloatTensor(image)
  
              images.append(image)
  
      return torch.stack(images).to(self.device)
  
file_path: serve/examples/image_classifier/near_real_time_video/near_real_time_video_handler.py
imports: import base64
  import io
  import torch
  import torch.nn.functional
  from PIL import Image
  from ts.torch_handler.image_classifier import ImageClassifier
  from ts.utils.util import map_class_to_label
label_desc: Use image node_id 2 for calling the NearRealTimeVideoHandler obj's underlying member method code with example usage: obj.preprocess(data) and returns: torch