code: def test_wgan():
      """Test fitting a conditional WGAN."""
  
      class ExampleWGAN(dc.models.WGAN):
          def get_noise_input_shape(self):
              return (2,)
  
          def get_data_input_shapes(self):
              return [(1,)]
  
          def get_conditional_input_shapes(self):
              return [(1,)]
  
          def create_generator(self):
              noise_input = Input(self.get_noise_input_shape())
              conditional_input = Input(
                  self.get_conditional_input_shapes()[0]
              )
              inputs = [noise_input, conditional_input]
              gen_in = Concatenate(axis=1)(inputs)
              output = Dense(1)(gen_in)
              return tf.keras.Model(inputs=inputs, outputs=output)
  
          def create_discriminator(self):
              data_input = Input(self.get_data_input_shapes()[0])
              conditional_input = Input(
                  self.get_conditional_input_shapes()[0]
              )
              inputs = [data_input, conditional_input]
              discrim_in = Concatenate(axis=1)(inputs)
              dense = Dense(10, activation=tf.nn.relu)(discrim_in)
              output = Dense(1)(dense)
              return tf.keras.Model(inputs=inputs, outputs=output)
  
      # We have to set the gradient penalty very small because the generator's
      # output is only a single number, so the default penalty would constrain
      # it far too much.
  
      gan = ExampleWGAN(learning_rate=0.01, gradient_penalty=0.1)
      gan.fit_gan(generate_data(gan, 1000, 100), generator_steps=0.1)
  
      # See if it has done a plausible job of learning the distribution.
  
      means = 10 * np.random.random([1000, 1])
      values = gan.predict_gan_generator(conditional_inputs=[means])
      deltas = values - means
      assert abs(np.mean(deltas)) < 1.0
      assert np.std(deltas) > 1.0
  
file_path: deepchem/deepchem/models/tests/test_gan.py
imports: import deepchem
  import numpy
  import pytest
  import tempfile
  from flaky import flaky
label_desc: Use image node_id 7 for calling a global function with example usage: test_wgan() and returns: int, list, list, tf, tf