class_docstr: A custom model handler implementation.
class_docstr_tok: ["A","custom","model","handler","implementation","."]
docstr: Invoke by TorchServe for prediction request.
  Do pre-processing of data, prediction using model and postprocessing of prediciton output
  :param data: Input data for prediction
  :param context: Initial context contains model server system properties.
  :return: prediction output
docstr_tok: ["Invoke","by","TorchServe","for","prediction","request",".","Do","pre-processing","of","data",",","prediction","using","model","and","postprocessing","of","prediciton","output",":","param","data",":","Input","data","for","prediction",":","param","context",":","Initial","context","contains","model","server","system","properties",".",":","return",":","prediction","output"]
code: def handle(self, data, context):
      """
      Invoke by TorchServe for prediction request.
      Do pre-processing of data, prediction using model and postprocessing of prediciton output
      :param data: Input data for prediction
      :param context: Initial context contains model server system properties.
      :return: prediction output
      """
      if isinstance(data, list):
          data = data[0]
      data = data.get("data") or data.get("body")
  
      # print('55-------', type(data)) # should be bytearray
  
      fp = tempfile.TemporaryFile()
      fp.write(data)
      fp.seek(0)
  
      waveform, sample_rate = torchaudio.load(fp)
      waveform = waveform.squeeze()
  
      feature_extractor = (
          EMFORMER_RNNT_BASE_LIBRISPEECH.get_feature_extractor()
      )
  
      decoder = self.model
  
      token_processor = (
          EMFORMER_RNNT_BASE_LIBRISPEECH.get_token_processor()
      )
  
      with torch.no_grad():
          features, length = feature_extractor(waveform)
          hypos = decoder(features, length, 1)
  
      # return batch_size = 1
      return [token_processor(hypos[0].tokens)]
  
file_path: serve/examples/asr_rnnt_emformer/handler.py
imports: import json
  import os
  import tempfile
  import torch
  import torchaudio
  from torchaudio.pipelines import EMFORMER_RNNT_BASE_LIBRISPEECH
label_desc: Use image node_id 3 for calling the ModelHandler obj's underlying member method code with example usage: obj.handle(data, context) and returns: list