docstr: Dense layer that extracts the feature map of a hidden layer in a model and computes
  output probabilities over that layer.
  
  Parameters
  ----------
  model
      tf.keras classification model.
  hidden_layer
      Hidden layer from model where feature map is extracted from.
  output_dim
      Output dimension for softmax layer.
  hidden_dim
      Dimension of optional additional dense layer.
docstr_tok: ["Dense","layer","that","extracts","the","feature","map","of","a","hidden","layer","in","a","model","and","computes","output","probabilities","over","that","layer",".","Parameters","--","--","--","--","--","model","tf.keras","classification","model",".","hidden_layer","Hidden","layer","from","model","where","feature","map","is","extracted","from",".","output_dim","Output","dimension","for","softmax","layer",".","hidden_dim","Dimension","of","optional","additional","dense","layer","."]
code: def __init__(
      self,
      model: tf.keras.Model,
      hidden_layer: int,
      output_dim: int,
      hidden_dim: int = None,
  ) -> None:
      """
      Dense layer that extracts the feature map of a hidden layer in a model and computes
      output probabilities over that layer.
  
      Parameters
      ----------
      model
          tf.keras classification model.
      hidden_layer
          Hidden layer from model where feature map is extracted from.
      output_dim
          Output dimension for softmax layer.
      hidden_dim
          Dimension of optional additional dense layer.
      """
      super(DenseHidden, self).__init__()
      self.partial_model = Model(
          inputs=model.inputs, outputs=model.layers[hidden_layer].output
      )
      for layer in self.partial_model.layers:  # freeze model layers
          layer.trainable = False
      self.hidden_dim = hidden_dim
      if hidden_dim is not None:
          self.dense_layer = Dense(hidden_dim, activation=tf.nn.relu)
      self.output_layer = Dense(output_dim, activation=tf.nn.softmax)
  
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 1 to create a new DenseHidden object from inherited base classes: tf.keras with example: obj = DenseHidden(model, hidden_layer, output_dim, hidden_dim)