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: Apply preprocessing and then transform the user input space into the model input space. This function is used
  by the ASR attack to attack into the PyTorchDeepSpeech estimator whose defences are called with the
  `_apply_preprocessing` function.
  
  :param x: Samples of shape (nb_samples, seq_length).
  :param y: Target values of shape (nb_samples). Each sample in `y` is a string and it may possess different
            lengths. A possible example of `y` could be: `y = np.array(['SIXTY ONE', 'HELLO'])`.
  :param real_lengths: Real lengths of original sequences.
  :return: A tuple of inputs and targets in the model space with the original index
           `(inputs, targets, input_percentages, target_sizes, batch_idx)`, where:
           - inputs: model inputs of shape (nb_samples, nb_frequencies, seq_length).
           - targets: ground truth targets of shape (sum over nb_samples of real seq_lengths).
           - input_percentages: percentages of real inputs in inputs.
           - target_sizes: list of real seq_lengths.
           - batch_idx: original index of inputs.
docstr_tok: ["Apply","preprocessing","and","then","transform","the","user","input","space","into","the","model","input","space",".","This","function","is","used","by","the","ASR","attack","to","attack","into","the","PyTorchDeepSpeech","estimator","whose","defences","are","called","with","the","`","_apply_preprocessing","`","function",".",":","param","x",":","Samples","of","shape","(","nb_samples",",","seq_length",")",".",":","param","y",":","Target","values","of","shape","(","nb_samples",")",".","Each","sample","in","`","y","`","is","a","string","and","it","may","possess","different","lengths",".","A","possible","example","of","`","y","`","could","be",":","`","y","=","np.array","(","[","'SIXTY","ONE","'",",","'HELLO","'","]",")","`",".",":","param","real_lengths",":","Real","lengths","of","original","sequences",".",":","return",":","A","tuple","of","inputs","and","targets","in","the","model","space","with","the","original","index","`","(","inputs",",","targets",",","input_percentages",",","target_sizes",",","batch_idx",")","`",",","where",":","-","inputs",":","model","inputs","of","shape","(","nb_samples",",","nb_frequencies",",","seq_length",")",".","-","targets",":","ground","truth","targets","of","shape","(","sum","over","nb_samples","of","real","seq_lengths",")",".","-","input_percentages",":","percentages","of","real","inputs","in","inputs",".","-","target_sizes",":","list","of","real","seq_lengths",".","-","batch_idx",":","original","index","of","inputs","."]
code: def _preprocess_transform_model_input(
      self,
      x: "torch.Tensor",
      y: np.ndarray,
  ) -> Tuple[Dict, List]:
      """
      Apply preprocessing and then transform the user input space into the model input space. This function is used
      by the ASR attack to attack into the PyTorchDeepSpeech estimator whose defences are called with the
      `_apply_preprocessing` function.
  
      :param x: Samples of shape (nb_samples, seq_length).
      :param y: Target values of shape (nb_samples). Each sample in `y` is a string and it may possess different
                lengths. A possible example of `y` could be: `y = np.array(['SIXTY ONE', 'HELLO'])`.
      :param real_lengths: Real lengths of original sequences.
      :return: A tuple of inputs and targets in the model space with the original index
               `(inputs, targets, input_percentages, target_sizes, batch_idx)`, where:
               - inputs: model inputs of shape (nb_samples, nb_frequencies, seq_length).
               - targets: ground truth targets of shape (sum over nb_samples of real seq_lengths).
               - input_percentages: percentages of real inputs in inputs.
               - target_sizes: list of real seq_lengths.
               - batch_idx: original index of inputs.
      """
      import torch
  
      # Apply preprocessing
      x_batch = []
      for i, _ in enumerate(x):
          preprocessed_x_i, _ = self._apply_preprocessing(
              x=x[i], y=None, no_grad=False
          )
          x_batch.append(preprocessed_x_i)
  
      x = torch.stack(x_batch)
  
      # Transform the input space
      batch_dict, batch_idx = self._transform_model_input(
          x=x,
          y=y,
          compute_gradient=False,
      )
  
      return batch_dict, batch_idx
  
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 6 for calling the PyTorchEspresso obj's underlying member method code with example usage: obj._preprocess_transform_model_input(x, y) and returns: batch_dict,  batch_idx