class_docstr: TextClassifier handler class. This handler takes a text (string) and
  as input and returns the classification text based on the model vocabulary.
class_docstr_tok: ["TextClassifier","handler","class",".","This","handler","takes","a","text","(","string",")","and","as","input","and","returns","the","classification","text","based","on","the","model","vocabulary","."]
docstr: Normalizes the input text for PyTorch model using following basic cleanup operations :
      - remove html tags
      - lowercase all text
      - expand contractions [like I'd -> I would, don't -> do not]
      - remove accented characters
      - remove punctuations
  Converts the normalized text to tensor using the source_vocab.
  
  Args:
      data (str): The input data is in the form of a string
  
  Returns:
      (Tensor): Text Tensor is returned after perfoming the pre-processing operations
      (str): The raw input is also returned in this function
docstr_tok: ["Normalizes","the","input","text","for","PyTorch","model","using","following","basic","cleanup","operations",":","-","remove","html","tags","-","lowercase","all","text","-","expand","contractions","[","like","I","'d","-",">","I","would",",","do","n't","-",">","do","not","]","-","remove","accented","characters","-","remove","punctuations","Converts","the","normalized","text","to","tensor","using","the","source_vocab",".","Args",":","data","(","str",")",":","The","input","data","is","in","the","form","of","a","string","Returns",":","(","Tensor",")",":","Text","Tensor","is","returned","after","perfoming","the","pre-processing","operations","(","str",")",":","The","raw","input","is","also","returned","in","this","function"]
code: def preprocess(self, data):
      """Normalizes the input text for PyTorch model using following basic cleanup operations :
          - remove html tags
          - lowercase all text
          - expand contractions [like I'd -> I would, don't -> do not]
          - remove accented characters
          - remove punctuations
      Converts the normalized text to tensor using the source_vocab.
  
      Args:
          data (str): The input data is in the form of a string
  
      Returns:
          (Tensor): Text Tensor is returned after perfoming the pre-processing operations
          (str): The raw input is also returned in this function
      """
  
      # Compat layer: normally the envelope should just return the data
      # directly, but older versions of Torchserve didn't have envelope.
      # Processing only the first input, not handling batch inference
  
      line = data[0]
      text = line.get("data") or line.get("body")
      # Decode text if not a str but bytes or bytearray
      if isinstance(text, (bytes, bytearray)):
          text = text.decode("utf-8")
  
      text = self._remove_html_tags(text)
      text = text.lower()
      text = self._expand_contractions(text)
      text = self._remove_accented_characters(text)
      text = self._remove_punctuation(text)
      text = self._tokenize(text)
      text_tensor = torch.as_tensor(
          [
              self.source_vocab[token]
              for token in ngrams_iterator(text, self.ngrams)
          ],
          device=self.device,
      )
      return text_tensor, text
  
file_path: serve/ts/torch_handler/text_classifier.py
imports: import logging
  import torch
  import torch.nn.functional
  from captum.attr import TokenReferenceBase
  from torchtext.data.utils import ngrams_iterator
  from ..utils.util import map_class_to_label
  from .text_handler import TextHandler
label_desc: Use image node_id 1 for calling the TextClassifier obj's underlying member method code with example usage: obj.preprocess(data) and returns: text_tensor,  text