class_docstr: Adversarially Learned Anomaly Detection (ALAD). 
  Paper: https://arxiv.org/pdf/1812.02288.pdf
  
  See :cite:`zenati2018adversarially` for details.
  
  Parameters
  ----------
  output_activation : str, optional (default=None)
      Activation function to use for output layers for encoder and dector.
      See https://keras.io/activations/
  
  activation_hidden_disc : str, optional (default='tanh')
      Activation function to use for hidden layers in discrimators.
      See https://keras.io/activations/
  
  activation_hidden_gen : str, optional (default='tanh')
      Activation function to use for hidden layers in encoder and decoder
      (i.e. generator).
      See https://keras.io/activations/
  
  epochs : int, optional (default=500)
      Number of epochs to train the model.
  
  batch_size : int, optional (default=32)
      Number of samples per gradient update.
  
  dropout_rate : float in (0., 1), optional (default=0.2)
      The dropout to be used across all layers.
  
  dec_layers : list, optional (default=[5,10,25])
      List that indicates the number of nodes per hidden layer for the d
      ecoder network.
      Thus, [10,10] indicates 2 hidden layers having each 10 nodes.
  
  enc_layers : list, optional (default=[25,10,5])
      List that indicates the number of nodes per hidden layer for the
      encoder network.
      Thus, [10,10] indicates 2 hidden layers having each 10 nodes.
  
  disc_xx_layers : list, optional (default=[25,10,5])
      List that indicates the number of nodes per hidden layer for
      discriminator_xx.
      Thus, [10,10] indicates 2 hidden layers having each 10 nodes.
  
  disc_zz_layers : list, optional (default=[25,10,5])
      List that indicates the number of nodes per hidden layer for
      discriminator_zz.
      Thus, [10,10] indicates 2 hidden layers having each 10 nodes.
  
  disc_xz_layers : list, optional (default=[25,10,5])
      List that indicates the number of nodes per hidden layer for
      discriminator_xz.
      Thus, [10,10] indicates 2 hidden layers having each 10 nodes.
  
  learning_rate_gen: float in (0., 1), optional (default=0.001)
      learning rate of training the encoder and decoder
  
  learning_rate_disc: float in (0., 1), optional (default=0.001)
      learning rate of training the discriminators
  
  add_recon_loss: bool optional (default=False)
      add an extra loss for encoder and decoder based on the reconstruction
      error
  
  lambda_recon_loss: float in (0., 1), optional (default=0.1)
      if ``add_recon_loss= True``, the reconstruction loss gets multiplied
      by ``lambda_recon_loss`` and added to the total loss for the generator
       (i.e. encoder and decoder).
  
  preprocessing : bool, optional (default=True)
      If True, apply standardization on the data.
  
  verbose : int, optional (default=1)
      Verbosity mode.
      - 0 = silent
      - 1 = progress bar
  
  contamination : float in (0., 0.5), optional (default=0.1)
      The amount of contamination of the data set, i.e.
      the proportion of outliers in the data set. When fitting this is used
      to define the threshold on the decision function.
  
  Attributes
  ----------
  decision_scores_ : numpy array of shape (n_samples,)
      The outlier scores of the training data [0,1].
      The higher, the more abnormal. Outliers tend to have higher
      scores. This value is available once the detector is
      fitted.
  
  threshold_ : float
      The threshold is based on ``contamination``. It is the
      ``n_samples * contamination`` most abnormal samples in
      ``decision_scores_``. The threshold is calculated for generating
      binary outlier labels.
  
  labels_ : int, either 0 or 1
      The binary labels of the training data. 0 stands for inliers
      and 1 for outliers/anomalies. It is generated by applying
      ``threshold_`` on ``decision_scores_``.
class_docstr_tok: ["Adversarially","Learned","Anomaly","Detection","(","ALAD",")",".","Paper",":","https",":","\/\/arxiv.org\/pdf\/1812.02288.pdf","See",":","cite",":","`","zenati2018adversarially","`","for","details",".","Parameters","--","--","--","--","--","output_activation",":","str",",","optional","(","default=None",")","Activation","function","to","use","for","output","layers","for","encoder","and","dector",".","See","https",":","\/\/keras.io\/activations\/","activation_hidden_disc",":","str",",","optional","(","default='tanh","'",")","Activation","function","to","use","for","hidden","layers","in","discrimators",".","See","https",":","\/\/keras.io\/activations\/","activation_hidden_gen",":","str",",","optional","(","default='tanh","'",")","Activation","function","to","use","for","hidden","layers","in","encoder","and","decoder","(","i.e",".","generator",")",".","See","https",":","\/\/keras.io\/activations\/","epochs",":","int",",","optional","(","default=500",")","Number","of","epochs","to","train","the","model",".","batch_size",":","int",",","optional","(","default=32",")","Number","of","samples","per","gradient","update",".","dropout_rate",":","float","in","(","0.",",","1",")",",","optional","(","default=0.2",")","The","dropout","to","be","used","across","all","layers",".","dec_layers",":","list",",","optional","(","default=","[","5,10,25","]",")","List","that","indicates","the","number","of","nodes","per","hidden","layer","for","the","d","ecoder","network",".","Thus",",","[","10,10","]","indicates","2","hidden","layers","having","each","10","nodes",".","enc_layers",":","list",",","optional","(","default=","[","25,10,5","]",")","List","that","indicates","the","number","of","nodes","per","hidden","layer","for","the","encoder","network",".","Thus",",","[","10,10","]","indicates","2","hidden","layers","having","each","10","nodes",".","disc_xx_layers",":","list",",","optional","(","default=","[","25,10,5","]",")","List","that","indicates","the","number","of","nodes","per","hidden","layer","for","discriminator_xx",".","Thus",",","[","10,10","]","indicates","2","hidden","layers","having","each","10","nodes",".","disc_zz_layers",":","list",",","optional","(","default=","[","25,10,5","]",")","List","that","indicates","the","number","of","nodes","per","hidden","layer","for","discriminator_zz",".","Thus",",","[","10,10","]","indicates","2","hidden","layers","having","each","10","nodes",".","disc_xz_layers",":","list",",","optional","(","default=","[","25,10,5","]",")","List","that","indicates","the","number","of","nodes","per","hidden","layer","for","discriminator_xz",".","Thus",",","[","10,10","]","indicates","2","hidden","layers","having","each","10","nodes",".","learning_rate_gen",":","float","in","(","0.",",","1",")",",","optional","(","default=0.001",")","learning","rate","of","training","the","encoder","and","decoder","learning_rate_disc",":","float","in","(","0.",",","1",")",",","optional","(","default=0.001",")","learning","rate","of","training","the","discriminators","add_recon_loss",":","bool","optional","(","default=False",")","add","an","extra","loss","for","encoder","and","decoder","based","on","the","reconstruction","error","lambda_recon_loss",":","float","in","(","0.",",","1",")",",","optional","(","default=0.1",")","if","``","add_recon_loss=","True","``",",","the","reconstruction","loss","gets","multiplied","by","``","lambda_recon_loss","``","and","added","to","the","total","loss","for","the","generator","(","i.e",".","encoder","and","decoder",")",".","preprocessing",":","bool",",","optional","(","default=True",")","If","True",",","apply","standardization","on","the","data",".","verbose",":","int",",","optional","(","default=1",")","Verbosity","mode",".","-","0","=","silent","-","1","=","progress","bar","contamination",":","float","in","(","0.",",","0.5",")",",","optional","(","default=0.1",")","The","amount","of","contamination","of","the","data","set",",","i.e",".","the","proportion","of","outliers","in","the","data","set",".","When","fitting","this","is","used","to","define","the","threshold","on","the","decision","function",".","Attributes","--","--","--","--","--","decision_scores_",":","numpy","array","of","shape","(","n_samples",",",")","The","outlier","scores","of","the","training","data","[","0,1","]",".","The","higher",",","the","more","abnormal",".","Outliers","tend","to","have","higher","scores",".","This","value","is","available","once","the","detector","is","fitted",".","threshold_",":","float","The","threshold","is","based","on","``","contamination","``",".","It","is","the","``","n_samples","*","contamination","``","most","abnormal","samples","in","``","decision_scores_","``",".","The","threshold","is","calculated","for","generating","binary","outlier","labels",".","labels_",":","int",",","either","0","or","1","The","binary","labels","of","the","training","data",".","0","stands","for","inliers","and","1","for","outliers\/anomalies",".","It","is","generated","by","applying","``","threshold_","``","on","``","decision_scores_","``","."]
code: def train_step(self, data):
      cross_entropy = tf.keras.losses.BinaryCrossentropy(
          from_logits=False
      )
  
      x_real, z_real = data
  
      def get_losses():
          y_true = tf.ones_like(x_real[:, [0]])
          y_fake = tf.zeros_like(x_real[:, [0]])
  
          # Generator
          x_gen = self.dec({"I1": z_real}, training=True)
  
          # Encoder
          z_gen = self.enc({"I1": x_real}, training=True)
  
          # Discriminatorxz
          out_truexz = self.disc_xz(
              {"I1": x_real, "I2": z_gen}, training=True
          )
          out_fakexz = self.disc_xz(
              {"I1": x_gen, "I2": z_real}, training=True
          )
  
          # Discriminatorzz
          if self.add_disc_zz_loss == True:
              out_truezz = self.disc_zz(
                  {"I1": z_real, "I2": z_real}, training=True
              )
              out_fakezz = self.disc_zz(
                  {
                      "I1": z_real,
                      "I2": self.enc(
                          {
                              "I1": self.dec(
                                  {"I1": z_real}, training=True
                              )
                          }
                      ),
                  },
                  training=True,
              )
  
              # Discriminatorxx
          out_truexx, _ = self.disc_xx(
              {"I1": x_real, "I2": x_real}, training=True
          )  # self.Dxx(x_real, x_real)
          out_fakexx, _ = self.disc_xx(
              {
                  "I1": x_real,
                  "I2": self.dec(
                      {"I1": self.enc({"I1": x_real}, training=True)}
                  ),
              },
              training=True,
          )
  
          # Losses for discriminators
          loss_dxz = cross_entropy(y_true, out_truexz) + cross_entropy(
              y_fake, out_fakexz
          )
          loss_dxx = cross_entropy(y_true, out_truexx) + cross_entropy(
              y_fake, out_fakexx
          )
          if self.add_disc_zz_loss == True:
              loss_dzz = cross_entropy(
                  y_true, out_truezz
              ) + cross_entropy(y_fake, out_fakezz)
              loss_disc = loss_dxz + loss_dzz + loss_dxx
          else:
              loss_disc = loss_dxz + loss_dxx
  
          # Losses for generator
          loss_gexz = cross_entropy(y_true, out_fakexz) + cross_entropy(
              y_fake, out_truexz
          )
          loss_gexx = cross_entropy(y_true, out_fakexx) + cross_entropy(
              y_fake, out_truexx
          )
          if self.add_disc_zz_loss == True:
              loss_gezz = cross_entropy(
                  y_true, out_fakezz
              ) + cross_entropy(y_fake, out_truezz)
              cycle_consistency = loss_gezz + loss_gexx
              loss_gen = loss_gexz + cycle_consistency
          else:
              cycle_consistency = loss_gexx
              loss_gen = loss_gexz + cycle_consistency
  
          if self.add_recon_loss == True:
              # Extra recon loss
              x_recon = self.dec(
                  {"I1": self.enc({"I1": x_real}, training=True)}
              )
              loss_recon = tf.reduce_mean((x_real - x_recon) ** 2)
              loss_gen += loss_recon * self.lambda_recon_loss
  
          return loss_disc, loss_gen
  
      with tf.GradientTape() as enc_tape, tf.GradientTape() as dec_tape, tf.GradientTape() as disc_xx_tape, tf.GradientTape() as disc_xz_tape, tf.GradientTape() as disc_zz_tape:
          loss_disc, loss_gen = get_losses()
  
      self.hist_loss_disc.append(np.float64(loss_disc.numpy()))
      self.hist_loss_gen.append(np.float64(loss_gen.numpy()))
  
      gradients_dec = dec_tape.gradient(
          loss_gen, self.dec.trainable_variables
      )
      self.dec.optimizer.apply_gradients(
          zip(gradients_dec, self.dec.trainable_variables)
      )
  
      gradients_enc = enc_tape.gradient(
          loss_gen, self.enc.trainable_variables
      )
      self.enc.optimizer.apply_gradients(
          zip(gradients_enc, self.enc.trainable_variables)
      )
  
      gradients_disc_xx = disc_xx_tape.gradient(
          loss_disc, self.disc_xx.trainable_variables
      )
      self.disc_xx.optimizer.apply_gradients(
          zip(gradients_disc_xx, self.disc_xx.trainable_variables)
      )
  
      if self.add_disc_zz_loss == True:
          gradients_disc_zz = disc_zz_tape.gradient(
              loss_disc, self.disc_zz.trainable_variables
          )
          self.disc_zz.optimizer.apply_gradients(
              zip(gradients_disc_zz, self.disc_zz.trainable_variables)
          )
  
      gradients_disc_xz = disc_xz_tape.gradient(
          loss_disc, self.disc_xz.trainable_variables
      )
      self.disc_xz.optimizer.apply_gradients(
          zip(gradients_disc_xz, self.disc_xz.trainable_variables)
      )
  
imports: from __future__ import division
  from __future__ import print_function
  import numpy
  import pandas
  from matplotlib import pyplot
  from sklearn.preprocessing import StandardScaler
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from .base import BaseDetector
  from .base_dl import _get_tensorflow_version
  from ..utils.utility import check_parameter
label_desc: Use image node_id 3 for calling the ALAD obj's underlying member method code with example usage: obj.train_step(data) and returns: loss_disc,  loss_gen