class_docstr: This class implements the imperceptible, robust, and targeted attack to generate adversarial examples for automatic
  speech recognition models. This attack will be implemented specifically for DeepSpeech model and is framework
  dependent, specifically for PyTorch.
  
  | Paper link: https://arxiv.org/abs/1903.10346
docstr: Generate a batch of adversarial samples and return them in an array.
  
  :param x: Samples of shape (nb_samples, seq_length). Note that, it is allowable that sequences in the batch
            could have different lengths. A possible example of `x` could be:
            `x = np.array([np.array([0.1, 0.2, 0.1, 0.4]), np.array([0.3, 0.1])])`.
  :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'])`. Note that, this
            class only supports targeted attack.
  :return: A batch of adversarial examples.
docstr_tok: ["Generate","a","batch","of","adversarial","samples","and","return","them","in","an","array",".",":","param","x",":","Samples","of","shape","(","nb_samples",",","seq_length",")",".","Note","that",",","it","is","allowable","that","sequences","in","the","batch","could","have","different","lengths",".","A","possible","example","of","`","x","`","could","be",":","`","x","=","np.array","(","[","np.array","(","[","0.1",",","0.2",",","0.1",",","0.4","]",")",",","np.array","(","[","0.3",",","0.1","]",")","]",")","`",".",":","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","'","]",")","`",".","Note","that",",","this","class","only","supports","targeted","attack",".",":","return",":","A","batch","of","adversarial","examples","."]
code: def _generate_batch(self, x: np.ndarray, y: np.ndarray) -> np.ndarray:
      """
      Generate a batch of adversarial samples and return them in an array.
  
      :param x: Samples of shape (nb_samples, seq_length). Note that, it is allowable that sequences in the batch
                could have different lengths. A possible example of `x` could be:
                `x = np.array([np.array([0.1, 0.2, 0.1, 0.4]), np.array([0.3, 0.1])])`.
      :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'])`. Note that, this
                class only supports targeted attack.
      :return: A batch of adversarial examples.
      """
      import torch
  
      # First stage of attack
      (
          successful_adv_input_1st_stage,
          original_input,
      ) = self._attack_1st_stage(x=x, y=y)
      successful_perturbation_1st_stage = (
          successful_adv_input_1st_stage
          - torch.tensor(original_input).to(self.estimator.device)
      )
  
      # Compute original masking threshold and maximum psd
      theta_batch = []
      original_max_psd_batch = []
  
      for _, x_i in enumerate(x):
          theta, original_max_psd = self._compute_masking_threshold(x_i)
          theta = theta.transpose(1, 0)
          theta_batch.append(theta)
          original_max_psd_batch.append(original_max_psd)
  
      # Reset delta with new result
      local_batch_shape = successful_adv_input_1st_stage.shape
      self.global_optimal_delta.data = torch.zeros(
          self.batch_size, self.global_max_length
      ).type(torch.float64)
      self.global_optimal_delta.data[
          : local_batch_shape[0], : local_batch_shape[1]
      ] = successful_perturbation_1st_stage
  
      # Second stage of attack
      successful_adv_input_2nd_stage = self._attack_2nd_stage(
          x=x,
          y=y,
          theta_batch=theta_batch,
          original_max_psd_batch=original_max_psd_batch,
      )
  
      results = successful_adv_input_2nd_stage.detach().cpu().numpy()
  
      return results
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import TYPE_CHECKING, Optional, Tuple, List
  import numpy
  import scipy
  from art.attacks.attack import EvasionAttack
  from art.estimators.pytorch import PyTorchEstimator
  from art.estimators.speech_recognition.pytorch_deep_speech import PyTorchDeepSpeech
  from art.estimators.speech_recognition.speech_recognizer import SpeechRecognizerMixin
  from art.estimators.speech_recognition.speech_recognizer import PytorchSpeechRecognizerMixin
label_desc: Use image node_id 3 for calling the ImperceptibleASRPyTorch obj's underlying member method code with example usage: obj._generate_batch(x, y) and returns: results