code: def preprocess(self, requests):
      assert (
          len(requests) == 1
      ), "GPT fast is currently only supported with batch_size=1"
      req_data = requests[0]
  
      input_data = req_data.get("data") or req_data.get("body")
  
      if isinstance(input_data, (bytes, bytearray)):
          input_data = input_data.decode("utf-8")
  
      if isinstance(input_data, str):
          input_data = json.loads(input_data)
  
      prompt = input_data["prompt"]
  
      encoded = encode_tokens(
          self.tokenizer, prompt, bos=True, device=self.device
      )
  
      self.prompt_length = encoded.size(0)
  
      return {
          "encoded": encoded,
          "max_new_tokens": input_data.get("max_new_tokens", 50),
      }
  
file_path: serve/examples/large_models/gpt_fast/handler.py
imports: import json
  import logging
  import time
  from pathlib import Path
  import torch
  from generate import Transformer, _load_model, decode_one_token, encode_tokens, logits_to_probs, maybe_init_dist, model_forward, multinomial_sample_one_no_sync, prefill
  from sentencepiece import SentencePieceProcessor
  from ts.handler_utils.timer import timed
  from ts.handler_utils.utils import send_intermediate_predict_response
  from ts.torch_handler.base_handler import BaseHandler
label_desc: Use image node_id 3 for calling the GptHandler obj's underlying member method code with example usage: obj.preprocess(requests) and returns: dict