class_docstr: Transformers handler class for sequence, token classification and question answering.
docstr: This function initialize and calls the layer integrated gradient to get word importance
  of the input text if captum explanation has been selected through setup_config
  Args:
      input_batch (int): Batches of tokens IDs of text
      text (str): The Text specified in the input request
      target (int): The Target can be set to any acceptable label under the user's discretion.
  Returns:
      (list): Returns a list of importances and words.
docstr_tok: ["This","function","initialize","and","calls","the","layer","integrated","gradient","to","get","word","importance","of","the","input","text","if","captum","explanation","has","been","selected","through","setup_config","Args",":","input_batch","(","int",")",":","Batches","of","tokens","IDs","of","text","text","(","str",")",":","The","Text","specified","in","the","input","request","target","(","int",")",":","The","Target","can","be","set","to","any","acceptable","label","under","the","user","'s","discretion",".","Returns",":","(","list",")",":","Returns","a","list","of","importances","and","words","."]
code: def get_insights(self, input_batch, text, target):
      """This function initialize and calls the layer integrated gradient to get word importance
      of the input text if captum explanation has been selected through setup_config
      Args:
          input_batch (int): Batches of tokens IDs of text
          text (str): The Text specified in the input request
          target (int): The Target can be set to any acceptable label under the user's discretion.
      Returns:
          (list): Returns a list of importances and words.
      """
  
      if self.setup_config["captum_explanation"]:
          embedding_layer = getattr(
              self.model, self.setup_config["embedding_name"]
          )
          embeddings = embedding_layer.embeddings
          self.lig = LayerIntegratedGradients(
              captum_sequence_forward, embeddings
          )
      else:
          logger.warning(
              "Captum Explanation is not chosen and will not be available"
          )
  
      if isinstance(text, (bytes, bytearray)):
          text = text.decode("utf-8")
      text_target = ast.literal_eval(text)
  
      if not self.setup_config["mode"] == "question_answering":
          text = text_target["text"]
      self.target = text_target["target"]
  
      input_ids, ref_input_ids, attention_mask = construct_input_ref(
          text, self.tokenizer, self.device, self.setup_config["mode"]
      )
      all_tokens = get_word_token(input_ids, self.tokenizer)
      response = {}
      response["words"] = all_tokens
      if (
          self.setup_config["mode"] == "sequence_classification"
          or self.setup_config["mode"] == "token_classification"
      ):
          attributions, delta = self.lig.attribute(
              inputs=input_ids,
              baselines=ref_input_ids,
              target=self.target,
              additional_forward_args=(attention_mask, 0, self.model),
              return_convergence_delta=True,
          )
  
          attributions_sum = summarize_attributions(attributions)
          response["importances"] = attributions_sum.tolist()
          response["delta"] = delta[0].tolist()
  
      elif self.setup_config["mode"] == "question_answering":
          attributions_start, delta_start = self.lig.attribute(
              inputs=input_ids,
              baselines=ref_input_ids,
              target=self.target,
              additional_forward_args=(attention_mask, 0, self.model),
              return_convergence_delta=True,
          )
          attributions_end, delta_end = self.lig.attribute(
              inputs=input_ids,
              baselines=ref_input_ids,
              target=self.target,
              additional_forward_args=(attention_mask, 1, self.model),
              return_convergence_delta=True,
          )
          attributions_sum_start = summarize_attributions(
              attributions_start
          )
          attributions_sum_end = summarize_attributions(
              attributions_end
          )
          response[
              "importances_answer_start"
          ] = attributions_sum_start.tolist()
          response[
              "importances_answer_end"
          ] = attributions_sum_end.tolist()
          response["delta_start"] = delta_start[0].tolist()
          response["delta_end"] = delta_end[0].tolist()
  
      return [response]
  
imports: import ast
  import json
  import logging
  import os
  from abc import ABC
  import torch
  import transformers
  from captum.attr import LayerIntegratedGradients
  from transformers import AutoModelForCausalLM, AutoModelForQuestionAnswering, AutoModelForSequenceClassification, AutoModelForTokenClassification, AutoTokenizer, GPT2TokenizerFast
  from ts.torch_handler.base_handler import BaseHandler
label_desc: Use image node_id 6 for calling the TransformersSeqClassifierHandler obj's underlying member method code with example usage: obj.get_insights(input_batch, text, target) and returns: list