class_docstr: This class implements a model-specific automatic speech recognizer using the end-to-end speech recognizer in
  Espresso.
  
  | Paper link: https://arxiv.org/abs/1909.08723
class_docstr_tok: ["This","class","implements","a","model-specific","automatic","speech","recognizer","using","the","end-to-end","speech","recognizer","in","Espresso",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1909.08723"]
docstr: Compute loss function and decoded output.
  
  :param masked_adv_input: The perturbed inputs.
  :param original_output: Target values of shape (nb_samples). Each sample in `original_output` is a string and
                          it may possess different lengths. A possible example of `original_output` could be:
                          `original_output = np.array(['SIXTY ONE', 'HELLO'])`.
  :return: The loss and the decoded output.
docstr_tok: ["Compute","loss","function","and","decoded","output",".",":","param","masked_adv_input",":","The","perturbed","inputs",".",":","param","original_output",":","Target","values","of","shape","(","nb_samples",")",".","Each","sample","in","`","original_output","`","is","a","string","and","it","may","possess","different","lengths",".","A","possible","example","of","`","original_output","`","could","be",":","`","original_output","=","np.array","(","[","'SIXTY","ONE","'",",","'HELLO","'","]",")","`",".",":","return",":","The","loss","and","the","decoded","output","."]
code: def compute_loss_and_decoded_output(
      self,
      masked_adv_input: "torch.Tensor",
      original_output: np.ndarray,
      **kwargs,
  ) -> Tuple["torch.Tensor", np.ndarray]:
      """
      Compute loss function and decoded output.
  
      :param masked_adv_input: The perturbed inputs.
      :param original_output: Target values of shape (nb_samples). Each sample in `original_output` is a string and
                              it may possess different lengths. A possible example of `original_output` could be:
                              `original_output = np.array(['SIXTY ONE', 'HELLO'])`.
      :return: The loss and the decoded output.
      """
      # Transform data into the model input space
      batch_dict, batch_idx = self._preprocess_transform_model_input(
          x=masked_adv_input.to(self.device),
          y=original_output,
      )
  
      # Compute the loss
      self.model.train()
      loss, _, _ = self.criterion(self.model, batch_dict)
  
      # Compute transcription
      def get_symbols_to_strip_from_output(generator):
          if hasattr(generator, "symbols_to_strip_from_output"):
              return generator.symbols_to_strip_from_output
  
          return {generator.eos, generator.pad}
  
      # Put the model in the eval mode
      self.model.eval()
  
      # Get decoded output
      decoded_output = []
      hypos = self.task.inference_step(
          self.generator, self._models, batch_dict
      )
  
      for _, hypos_i in enumerate(hypos):
          # Process top predictions
          for _, hypo in enumerate(hypos_i[: self.esp_args.nbest]):
              hypo_str = self.dictionary.string(
                  hypo["tokens"].int().cpu(),
                  bpe_symbol=None,
                  extra_symbols_to_ignore=get_symbols_to_strip_from_output(
                      self.generator
                  ),
              )  # not removing bpe at this point
              detok_hypo_str = self.bpe.decode(hypo_str)
              decoded_output.append(detok_hypo_str)
  
      decoded_output_array = np.array(decoded_output)
      decoded_output_copy = decoded_output_array.copy()
      decoded_output_array[
          batch_idx
      ] = decoded_output_copy  # revert decoded output to its original order
  
      return loss, decoded_output_array
  
imports: import ast
  from argparse import Namespace
  import logging
  from typing import Dict, List, Optional, Tuple, TYPE_CHECKING, Union
  import numpy
  from art import config
  from art.estimators.pytorch import PyTorchEstimator
  from art.estimators.speech_recognition.speech_recognizer import SpeechRecognizerMixin, PytorchSpeechRecognizerMixin
  from art.utils import get_file
label_desc: Use image node_id 7 for calling the PyTorchEspresso obj's underlying member method code with example usage: obj.compute_loss_and_decoded_output(masked_adv_input, original_output) and returns: loss,  decoded_output_array, unknown, generator