class_docstr: Transformers handler class for text completion streaming on Inferentia2
class_docstr_tok: ["Transformers","handler","class","for","text","completion","streaming","on","Inferentia2"]
code: def inference(self, tokenized_input):
      generation_kwargs = dict(
          tokenized_input,
          streamer=self.output_streamer,
          max_new_tokens=self.max_length,
      )
      self.model.reset_generation()
      thread = Thread(
          target=self.model.generate, kwargs=generation_kwargs
      )
      thread.start()
  
      micro_batch_idx = self.handle.get_micro_batch_idx()
      micro_batch_req_id_map = self.get_micro_batch_req_id_map(
          micro_batch_idx
      )
      for new_text in self.output_streamer:
          logger.debug("send response stream")
          send_intermediate_predict_response(
              new_text[: len(micro_batch_req_id_map)],
              micro_batch_req_id_map,
              "Intermediate Prediction success",
              200,
              self.context,
          )
  
      thread.join()
  
      return [""] * len(micro_batch_req_id_map)
  
imports: import logging
  import os
  from abc import ABC
  from threading import Thread
  import torch_neuronx
  from transformers import AutoConfig, LlamaTokenizer
  from transformers_neuronx.generation_utils import HuggingFaceGenerationModelAdapter
  from transformers_neuronx.llama.model import LlamaForSampling
  from ts.handler_utils.hf_batch_streamer import TextIteratorStreamerBatch
  from ts.handler_utils.micro_batching import MicroBatching
  from ts.protocol.otf_message_handler import send_intermediate_predict_response
  from ts.torch_handler.base_handler import BaseHandler
label_desc: Use image node_id 4 for calling the LLMHandler obj's underlying member method code with example usage: obj.inference(tokenized_input) and returns: unknown