docstr: Model distillation concept drift and adversarial detector.
  
  Parameters
  ----------
  threshold
      Threshold used for score to determine adversarial instances.
  distilled_model
      A tf.keras model to distill.
  model
      A trained tf.keras classification model.
  loss_type
      Loss for distillation. Supported: 'kld', 'xent'
  temperature
      Temperature used for model prediction scaling.
      Temperature <1 sharpens the prediction probability distribution.
  data_type
      Optionally specifiy the data type (tabular, image or time-series). Added to metadata.
docstr_tok: ["Model","distillation","concept","drift","and","adversarial","detector",".","Parameters","--","--","--","--","--","threshold","Threshold","used","for","score","to","determine","adversarial","instances",".","distilled_model","A","tf.keras","model","to","distill",".","model","A","trained","tf.keras","classification","model",".","loss_type","Loss","for","distillation",".","Supported",":","'kld","'",",","'xent'","temperature","Temperature","used","for","model","prediction","scaling",".","Temperature","<","1","sharpens","the","prediction","probability","distribution",".","data_type","Optionally","specifiy","the","data","type","(","tabular",",","image","or","time-series",")",".","Added","to","metadata","."]
code: def __init__(
      self,
      threshold: float = None,
      distilled_model: tf.keras.Model = None,
      model: tf.keras.Model = None,
      loss_type: str = "kld",
      temperature: float = 1.0,
      data_type: str = None,
  ) -> None:
      """
      Model distillation concept drift and adversarial detector.
  
      Parameters
      ----------
      threshold
          Threshold used for score to determine adversarial instances.
      distilled_model
          A tf.keras model to distill.
      model
          A trained tf.keras classification model.
      loss_type
          Loss for distillation. Supported: 'kld', 'xent'
      temperature
          Temperature used for model prediction scaling.
          Temperature <1 sharpens the prediction probability distribution.
      data_type
          Optionally specifiy the data type (tabular, image or time-series). Added to metadata.
      """
      super().__init__()
  
      if threshold is None:
          logger.warning(
              "No threshold level set. Need to infer threshold using `infer_threshold`."
          )
  
      self.threshold = threshold
      self.model = model
      for layer in self.model.layers:  # freeze model layers
          layer.trainable = False
  
      if isinstance(distilled_model, tf.keras.Model):
          self.distilled_model = distilled_model
      else:
          raise TypeError(
              "No valid format detected for `distilled_model` (tf.keras.Model) "
          )
      self.loss_type = loss_type
      self.temperature = temperature
  
      # set metadata
      self.meta["detector_type"] = "adversarial"
      self.meta["data_type"] = data_type
      self.meta["online"] = False
  
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 1 to create a new ModelDistillation object from inherited base classes: BaseDetector, FitMixin, ThresholdMixin with example: obj = ModelDistillation(threshold, distilled_model, model, loss_type, temperature, data_type)