docstr: Update threshold by a value inferred from the percentage of instances considered to be
  adversarial in a sample of the dataset.
  
  Parameters
  ----------
  X
      Batch of instances.
  threshold_perc
      Percentage of X considered to be normal based on the adversarial score.
  margin
      Add margin to threshold. Useful if adversarial instances have significantly higher scores and there
      is no adversarial instance in X.
  batch_size
      Batch size used when computing scores.
docstr_tok: ["Update","threshold","by","a","value","inferred","from","the","percentage","of","instances","considered","to","be","adversarial","in","a","sample","of","the","dataset",".","Parameters","--","--","--","--","--","X","Batch","of","instances",".","threshold_perc","Percentage","of","X","considered","to","be","normal","based","on","the","adversarial","score",".","margin","Add","margin","to","threshold",".","Useful","if","adversarial","instances","have","significantly","higher","scores","and","there","is","no","adversarial","instance","in","X.","batch_size","Batch","size","used","when","computing","scores","."]
code: def infer_threshold(
      self,
      X: np.ndarray,
      threshold_perc: float = 99.0,
      margin: float = 0.0,
      batch_size: int = int(1e10),
  ) -> None:
      """
      Update threshold by a value inferred from the percentage of instances considered to be
      adversarial in a sample of the dataset.
  
      Parameters
      ----------
      X
          Batch of instances.
      threshold_perc
          Percentage of X considered to be normal based on the adversarial score.
      margin
          Add margin to threshold. Useful if adversarial instances have significantly higher scores and there
          is no adversarial instance in X.
      batch_size
          Batch size used when computing scores.
      """
      # compute adversarial scores
      adv_score = self.score(X, batch_size=batch_size)
  
      # update threshold
      self.threshold = np.percentile(adv_score, threshold_perc) + margin
  
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 3 for calling the AdversarialAE obj's underlying member method code with example usage: obj.infer_threshold(X, threshold_perc, margin, batch_size) without return types