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.
      """
  
      # model predictions
      y = predict_batch(X, self.model, batch_size=batch_size)
      y_distilled = predict_batch(
          X, self.distilled_model, batch_size=batch_size
      )
      y = cast(np.ndarray, y)  # help mypy out
      y_distilled = cast(np.ndarray, y_distilled)  # 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()
  
      if self.loss_type == "kld":
          score = kld(y, y_distilled).numpy()
      elif self.loss_type == "xent":
          score = categorical_crossentropy(y, y_distilled).numpy()
      else:
          raise NotImplementedError
  
      if return_predictions:
          return score, y, y_distilled
      else:
          return score
  
file_path: alibi-detect/alibi_detect/ad/model_distillation.py
imports: import logging
  from typing import Callable, Dict, Tuple, Union, cast
  import numpy
  import tensorflow
  from alibi_detect.base import BaseDetector, FitMixin, ThresholdMixin, adversarial_prediction_dict
  from alibi_detect.models.tensorflow.losses import loss_distillation
  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.losses import categorical_crossentropy, kld
label_desc: Use image node_id 4 for calling the ModelDistillation obj's underlying member method code with example usage: obj.score(X, batch_size, return_predictions) and returns: score,  y,  y_distilled, score