class_docstr: Implements Wasserstein Generative Adversarial Networks.
  
  This class implements Wasserstein Generative Adversarial Networks (WGANs) as
  described in Arjovsky et al., "Wasserstein GAN" (https://arxiv.org/abs/1701.07875).
  A WGAN is conceptually rather different from a conventional GAN, but in
  practical terms very similar.  It reinterprets the discriminator (often called
  the "critic" in this context) as learning an approximation to the Earth Mover
  distance between the training and generated distributions.  The generator is
  then trained to minimize that distance.  In practice, this just means using
  slightly different loss functions for training the generator and discriminator.
  
  WGANs have theoretical advantages over conventional GANs, and they often work
  better in practice.  In addition, the discriminator's loss function can be
  directly interpreted as a measure of the quality of the model.  That is an
  advantage over conventional GANs, where the loss does not directly convey
  information about the quality of the model.
  
  The theory WGANs are based on requires the discriminator's gradient to be
  bounded.  The original paper achieved this by clipping its weights.  This
  class instead does it by adding a penalty term to the discriminator's loss, as
  described in https://arxiv.org/abs/1704.00028.  This is sometimes found to
  produce better results.
  
  There are a few other practical differences between GANs and WGANs.  In a
  conventional GAN, the discriminator's output must be between 0 and 1 so it can
  be interpreted as a probability.  In a WGAN, it should produce an unbounded
  output that can be interpreted as a distance.
  
  When training a WGAN, you also should usually use a smaller value for
  generator_steps.  Conventional GANs rely on keeping the generator and
  discriminator "in balance" with each other.  If the discriminator ever gets
  too good, it becomes impossible for the generator to fool it and training
  stalls.  WGANs do not have this problem, and in fact the better the
  discriminator is, the easier it is for the generator to improve.  It therefore
  usually works best to perform several training steps on the discriminator for
  each training step on the generator.
class_docstr_tok: ["Implements","Wasserstein","Generative","Adversarial","Networks",".","This","class","implements","Wasserstein","Generative","Adversarial","Networks","(","WGANs",")","as","described","in","Arjovsky","et","al.",",","``","Wasserstein","GAN","''","(","https",":","\/\/arxiv.org\/abs\/1701.07875",")",".","A","WGAN","is","conceptually","rather","different","from","a","conventional","GAN",",","but","in","practical","terms","very","similar",".","It","reinterprets","the","discriminator","(","often","called","the","``","critic","''","in","this","context",")","as","learning","an","approximation","to","the","Earth","Mover","distance","between","the","training","and","generated","distributions",".","The","generator","is","then","trained","to","minimize","that","distance",".","In","practice",",","this","just","means","using","slightly","different","loss","functions","for","training","the","generator","and","discriminator",".","WGANs","have","theoretical","advantages","over","conventional","GANs",",","and","they","often","work","better","in","practice",".","In","addition",",","the","discriminator","'s","loss","function","can","be","directly","interpreted","as","a","measure","of","the","quality","of","the","model",".","That","is","an","advantage","over","conventional","GANs",",","where","the","loss","does","not","directly","convey","information","about","the","quality","of","the","model",".","The","theory","WGANs","are","based","on","requires","the","discriminator","'s","gradient","to","be","bounded",".","The","original","paper","achieved","this","by","clipping","its","weights",".","This","class","instead","does","it","by","adding","a","penalty","term","to","the","discriminator","'s","loss",",","as","described","in","https",":","\/\/arxiv.org\/abs\/1704.00028",".","This","is","sometimes","found","to","produce","better","results",".","There","are","a","few","other","practical","differences","between","GANs","and","WGANs",".","In","a","conventional","GAN",",","the","discriminator","'s","output","must","be","between","0","and","1","so","it","can","be","interpreted","as","a","probability",".","In","a","WGAN",",","it","should","produce","an","unbounded","output","that","can","be","interpreted","as","a","distance",".","When","training","a","WGAN",",","you","also","should","usually","use","a","smaller","value","for","generator_steps",".","Conventional","GANs","rely","on","keeping","the","generator","and","discriminator","``","in","balance","''","with","each","other",".","If","the","discriminator","ever","gets","too","good",",","it","becomes","impossible","for","the","generator","to","fool","it","and","training","stalls",".","WGANs","do","not","have","this","problem",",","and","in","fact","the","better","the","discriminator","is",",","the","easier","it","is","for","the","generator","to","improve",".","It","therefore","usually","works","best","to","perform","several","training","steps","on","the","discriminator","for","each","training","step","on","the","generator","."]
code: def _call_discriminator(self, discriminator, inputs, train):
      if train:
          penalty = GradientPenaltyLayer(self, discriminator)
          return penalty(inputs, self.conditional_input_layers)
      return discriminator(
          _list_or_tensor(inputs + self.conditional_input_layers)
      )
  
imports: from deepchem.models import KerasModel, layers
  from tensorflow.keras.layers import Input, Lambda, Layer, Softmax, Reshape, Multiply
  import numpy
  import tensorflow
  import time
label_desc: Use image node_id 2 for calling the WGAN obj's underlying member method code with example usage: obj._call_discriminator(discriminator, inputs, train) and returns: discriminator, penalty