class_docstr: Transformers handler class for sequence, token classification and question answering.
class_docstr_tok: ["Transformers","handler","class","for","sequence",",","token","classification","and","question","answering","."]
docstr: Predicts the class (or classes) of the received text using the serialized transformers
  checkpoint.
  Args:
      input_batch (tuple): A tuple with two tensors: the batch of input ids and the batch
                          of attention masks, as returned by the preprocess function.
  Returns:
      list: A list of strings with the predicted values for each input text in the batch.
docstr_tok: ["Predicts","the","class","(","or","classes",")","of","the","received","text","using","the","serialized","transformers","checkpoint",".","Args",":","input_batch","(","tuple",")",":","A","tuple","with","two","tensors",":","the","batch","of","input","ids","and","the","batch","of","attention","masks",",","as","returned","by","the","preprocess","function",".","Returns",":","list",":","A","list","of","strings","with","the","predicted","values","for","each","input","text","in","the","batch","."]
code: def inference(self, input_batch):
      """
      Predicts the class (or classes) of the received text using the serialized transformers
      checkpoint.
      Args:
          input_batch (tuple): A tuple with two tensors: the batch of input ids and the batch
                              of attention masks, as returned by the preprocess function.
      Returns:
          list: A list of strings with the predicted values for each input text in the batch.
      """
      input_ids_batch, attention_mask_batch = input_batch
      input_ids_batch = input_ids_batch.to(self.device)
      outputs = self.model.generate(
          input_ids_batch,
          attention_mask=attention_mask_batch,
          max_length=self.max_new_tokens,
      )
  
      inferences = self.tokenizer.batch_decode(
          outputs,
          skip_special_tokens=True,
          clean_up_tokenization_spaces=False,
      )
  
      logger.info("Generated text: %s", inferences)
      return inferences
  
file_path: serve/examples/large_models/deepspeed/custom_handler.py
imports: import logging
  from abc import ABC
  import torch
  import transformers
  from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
  from ts.context import Context
  from ts.handler_utils.distributed.deepspeed import get_ds_engine
  from ts.torch_handler.distributed.base_deepspeed_handler import BaseDeepSpeedHandler
label_desc: Use image node_id 5 for calling the TransformersSeqClassifierHandler obj's underlying member method code with example usage: obj.inference(input_batch) and returns: inferences