docstr: Preprocess function to convert the request input to a tensor(Torchserve supported format).
  The user needs to override to customize the pre-processing
  
  Args :
      data (list): List of the data from the request input.
  
  Returns:
      tensor: Returns the tensor data of the input
docstr_tok: ["Preprocess","function","to","convert","the","request","input","to","a","tensor","(","Torchserve","supported","format",")",".","The","user","needs","to","override","to","customize","the","pre-processing","Args",":","data","(","list",")",":","List","of","the","data","from","the","request","input",".","Returns",":","tensor",":","Returns","the","tensor","data","of","the","input"]
code: def preprocess(self, data):
      """
      Preprocess function to convert the request input to a tensor(Torchserve supported format).
      The user needs to override to customize the pre-processing
  
      Args :
          data (list): List of the data from the request input.
  
      Returns:
          tensor: Returns the tensor data of the input
      """
  
      self.sequence_ids = {}
      results = []
      for idx, row in enumerate(data):
          sequence_id = self.context.get_sequence_id(idx)
  
          prev = int(0)
          if self.cache.has_key(sequence_id):
              prev = int(self.cache[sequence_id])
  
          request = row.get("data") or row.get("body")
          if isinstance(request, (bytes, bytearray)):
              request = request.decode("utf-8")
  
          val = prev + int(request)
          self.cache[sequence_id] = val
          results.append(val)
  
      return results
  
file_path: serve/examples/stateful/stateful_handler.py
imports: import logging
  from abc import ABC
  from typing import Dict
  from lru import LRU
  from ts.context import Context
  from ts.torch_handler.base_handler import BaseHandler
label_desc: Use image node_id 3 for calling the StatefulHandler obj's underlying member method code with example usage: obj.preprocess(data) and returns: results