class_docstr: Base class for all vision handlers
docstr: The preprocess function of MNIST program converts the input data to a float tensor
  
  Args:
      data (List): Input data from the request is in the form of a Tensor
  
  Returns:
      list : The preprocess function returns the input image as a list of float tensors.
docstr_tok: ["The","preprocess","function","of","MNIST","program","converts","the","input","data","to","a","float","tensor","Args",":","data","(","List",")",":","Input","data","from","the","request","is","in","the","form","of","a","Tensor","Returns",":","list",":","The","preprocess","function","returns","the","input","image","as","a","list","of","float","tensors","."]
code: def preprocess(self, data):
      """The preprocess function of MNIST program converts the input data to a float tensor
  
      Args:
          data (List): Input data from the request is in the form of a Tensor
  
      Returns:
          list : The preprocess function returns the input image as a list of float tensors.
      """
      images = []
  
      for row in data:
          # Compat layer: normally the envelope should just return the data
          # directly, but older versions of Torchserve didn't have envelope.
          image = row.get("data") or row.get("body")
          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/ts/torch_handler/vision_handler.py
imports: import base64
  import io
  from abc import ABC
  import torch
  from captum.attr import IntegratedGradients
  from PIL import Image
  from ts.handler_utils.timer import timed
  from .base_handler import BaseHandler
label_desc: Use image node_id 2 for calling the VisionHandler obj's underlying member method code with example usage: obj.preprocess(data) and returns: torch