class_docstr: HiFiC Model class.
class_docstr_tok: ["HiFiC","Model","class","."]
docstr: Create training op for generator.
  
  This also create the optimizers for the encoder/decoder and entropy
  layers.
  
  Args:
    nodes: The output of the model to create a R-D loss and feed to D.
    bpp_pair: Instance of BppPair.
    step: the global step of G.
  
  Returns:
    A training op if training, else None
docstr_tok: ["Create","training","op","for","generator",".","This","also","create","the","optimizers","for","the","encoder\/decoder","and","entropy","layers",".","Args",":","nodes",":","The","output","of","the","model","to","create","a","R-D","loss","and","feed","to","D.","bpp_pair",":","Instance","of","BppPair",".","step",":","the","global","step","of","G.","Returns",":","A","training","op","if","training",",","else","None"]
code: def _train_generator(self, nodes: Nodes, bpp_pair: BppPair, step):
      """Create training op for generator.
  
      This also create the optimizers for the encoder/decoder and entropy
      layers.
  
      Args:
        nodes: The output of the model to create a R-D loss and feed to D.
        bpp_pair: Instance of BppPair.
        step: the global step of G.
  
      Returns:
        A training op if training, else None
      """
      rd_loss = self._create_rd_loss(nodes, bpp_pair, step)
  
      with tf.name_scope("train_gen"):
          if self._setup_discriminator:
              d_outs = self._compute_discriminator_out(
                  nodes,
                  create_summaries=False,
                  gradients_to_generator=True,
              )
              g_loss = self._create_gan_loss(
                  d_outs, create_summaries=True, mode="g_loss"
              )
              scaled_g_loss = self._loss_scaler.get_scaled_g_loss(
                  g_loss
              )
              tf.summary.scalar("scaled_g_loss", scaled_g_loss)
              loss_enc_dec_entropy = rd_loss + scaled_g_loss
  
          else:
              loss_enc_dec_entropy = rd_loss
  
          if self._lpips_loss is not None:
              tf.logging.info("Using LPIPS...")
              perceptual_loss = self._compute_perceptual_loss(nodes)
              weighted_perceptual_loss = (
                  self._lpips_loss_weight * perceptual_loss
              )
              tf.summary.scalar(
                  "weighted_lpips", weighted_perceptual_loss
              )
              loss_enc_dec_entropy += weighted_perceptual_loss
  
          tf.summary.scalar(
              "loss_enc_dec_entropy", loss_enc_dec_entropy
          )
  
          if self.training:
              self._add_hook(
                  tf.train.NanTensorHook(loss_enc_dec_entropy)
              )
  
          if self.validation:
              return None
  
          (
              entropy_vars,
              transform_vars,
              _,
          ) = self._get_and_check_variables()
  
          # Train G.
          with tf.name_scope("min_g"):
              train_op = self._make_enc_dec_entropy_train_op(
                  step,
                  loss_enc_dec_entropy,
                  entropy_vars,
                  transform_vars,
              )
  
          return train_op
  
imports: import collections
  import glob
  import itertools
  from compare_gan.gans import loss_lib
  import tensorflow.compat.v1
  import tensorflow_datasets
  from hific import archs
  from hific import helpers
  from hific.helpers import ModelMode
  from hific.helpers import ModelType
  from hific.helpers import TFDSArguments
label_desc: Use image node_id 26 for calling the HiFiC obj's underlying member method code with example usage: obj._train_generator(nodes, bpp_pair, step) and returns: train_op, None