docstr: Compute adversarial scores.
  
  Parameters
  ----------
  X
      Batch of instances to analyze.
  batch_size
      Batch size used when computing scores.
  return_predictions
      Whether to return the predictions of the classifier on the original and reconstructed instances.
  
  Returns
  -------
  Array with adversarial scores for each instance in the batch.
docstr_tok: ["Compute","adversarial","scores",".","Parameters","--","--","--","--","--","X","Batch","of","instances","to","analyze",".","batch_size","Batch","size","used","when","computing","scores",".","return_predictions","Whether","to","return","the","predictions","of","the","classifier","on","the","original","and","reconstructed","instances",".","Returns","--","--","--","-","Array","with","adversarial","scores","for","each","instance","in","the","batch","."]
code: def score(
      self,
      X: np.ndarray,
      batch_size: int = int(1e10),
      return_predictions: bool = False,
  ) -> Union[np.ndarray, Tuple[np.ndarray, np.ndarray, np.ndarray]]:
      """
      Compute adversarial scores.
  
      Parameters
      ----------
      X
          Batch of instances to analyze.
      batch_size
          Batch size used when computing scores.
      return_predictions
          Whether to return the predictions of the classifier on the original and reconstructed instances.
  
      Returns
      -------
      Array with adversarial scores for each instance in the batch.
      """
      # reconstructed instances
      X_recon = predict_batch(X, self.ae, batch_size=batch_size)
  
      # model predictions
      y = predict_batch(X, self.model, batch_size=batch_size)
      y_recon = predict_batch(
          X_recon, self.model, batch_size=batch_size
      )
      y = cast(np.ndarray, y)  # help mypy out
      y_recon = cast(np.ndarray, y_recon)  # help mypy out
  
      # scale predictions
      if self.temperature != 1.0:
          y = y ** (1 / self.temperature)
          y = (
              y / tf.reshape(tf.reduce_sum(y, axis=-1), (-1, 1))
          ).numpy()
  
      adv_score = kld(y, y_recon).numpy()
  
      # hidden layer predictions
      if isinstance(self.model_hl, list):
          for m, w in zip(self.model_hl, self.w_model_hl):
              h = predict_batch(X, m, batch_size=batch_size)
              h_recon = predict_batch(X_recon, m, batch_size=batch_size)
              adv_score += w * kld(h, h_recon).numpy()
  
      if return_predictions:
          return adv_score, y, y_recon
      else:
          return adv_score
  
imports: import logging
  from typing import Callable, Dict, List, Tuple, Union, cast
  import numpy
  import tensorflow
  from alibi_detect.base import BaseDetector, FitMixin, ThresholdMixin, adversarial_correction_dict, adversarial_prediction_dict
  from alibi_detect.models.tensorflow.autoencoder import AE
  from alibi_detect.models.tensorflow.losses import loss_adv_ae
  from alibi_detect.models.tensorflow.trainer import trainer
  from alibi_detect.utils.tensorflow.prediction import predict_batch
  from alibi_detect.utils._types import OptimizerTF
  from tensorflow.keras.layers import Dense, Flatten
  from tensorflow.keras.losses import kld
  from tensorflow.keras.models import Model
label_desc: Use image node_id 4 for calling the AdversarialAE obj's underlying member method code with example usage: obj.score(X, batch_size, return_predictions) and returns: adv_score,  y,  y_recon, adv_score