code: def __init__(
      self,
      env,
      hidden_size,
      entcoeff=0.001,
      lr_rate=1e-3,
      scope="adversary",
  ):
      self.scope = scope
      self.observation_shape = env.observation_space.shape
      self.actions_shape = env.action_space.shape
      self.input_shape = tuple(
          [
              o + a
              for o, a in zip(
                  self.observation_shape, self.actions_shape
              )
          ]
      )
      self.num_actions = env.action_space.shape[0]
      self.hidden_size = hidden_size
      self.build_ph()
      # Build grpah
      generator_logits = self.build_graph(
          self.generator_obs_ph, self.generator_acs_ph, reuse=False
      )
      expert_logits = self.build_graph(
          self.expert_obs_ph, self.expert_acs_ph, reuse=True
      )
      # Build accuracy
      generator_acc = tf.reduce_mean(
          tf.to_float(tf.nn.sigmoid(generator_logits) < 0.5)
      )
      expert_acc = tf.reduce_mean(
          tf.to_float(tf.nn.sigmoid(expert_logits) > 0.5)
      )
      # Build regression loss
      # let x = logits, z = targets.
      # z * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x))
      generator_loss = tf.nn.sigmoid_cross_entropy_with_logits(
          logits=generator_logits,
          labels=tf.zeros_like(generator_logits),
      )
      generator_loss = tf.reduce_mean(generator_loss)
      expert_loss = tf.nn.sigmoid_cross_entropy_with_logits(
          logits=expert_logits, labels=tf.ones_like(expert_logits)
      )
      expert_loss = tf.reduce_mean(expert_loss)
      # Build entropy loss
      logits = tf.concat([generator_logits, expert_logits], 0)
      entropy = tf.reduce_mean(logit_bernoulli_entropy(logits))
      entropy_loss = -entcoeff * entropy
      # Loss + Accuracy terms
      self.losses = [
          generator_loss,
          expert_loss,
          entropy,
          entropy_loss,
          generator_acc,
          expert_acc,
      ]
      self.loss_name = [
          "generator_loss",
          "expert_loss",
          "entropy",
          "entropy_loss",
          "generator_acc",
          "expert_acc",
      ]
      self.total_loss = generator_loss + expert_loss + entropy_loss
      # Build Reward for policy
      self.reward_op = -tf.log(
          1 - tf.nn.sigmoid(generator_logits) + 1e-8
      )
      var_list = self.get_trainable_variables()
      self.lossandgrad = U.function(
          [
              self.generator_obs_ph,
              self.generator_acs_ph,
              self.expert_obs_ph,
              self.expert_acs_ph,
          ],
          self.losses + [U.flatgrad(self.total_loss, var_list)],
      )
  
file_path: baselines/baselines/gail/adversary.py
imports: import tensorflow
  import numpy
  from baselines.common.mpi_running_mean_std import RunningMeanStd
  from baselines.common import tf_util
label_desc: Use image node_id 1 to create a new TransitionClassifier object from inherited base classes: object with example: obj = TransitionClassifier(env, hidden_size, entcoeff, lr_rate, scope)