class_docstr: HiFiC Model class.
class_docstr_tok: ["HiFiC","Model","class","."]
docstr: Create GAN loss using compare_gan.
docstr_tok: ["Create","GAN","loss","using","compare_gan","."]
code: def _create_gan_loss(
      self,
      d_out: archs.DiscOutSplit,
      create_summaries=True,
      mode="g_loss",
  ):
      """Create GAN loss using compare_gan."""
      if mode not in ("g_loss", "d_loss"):
          raise ValueError("Invalid mode: {}".format(mode))
      assert self._gan_loss_function is not None
  
      # Called within either train_disc or train_gen namescope.
      with tf.name_scope("gan_loss"):
          d_loss, _, _, g_loss = compare_gan_loss_lib.get_losses(
              # Note: some fn's need other args.
              fn=self._gan_loss_function,
              d_real=d_out.d_real,
              d_fake=d_out.d_fake,
              d_real_logits=d_out.d_real_logits,
              d_fake_logits=d_out.d_fake_logits,
          )
          loss = d_loss if mode == "d_loss" else g_loss
          if create_summaries:
              tf.summary.scalar("d_loss", d_loss)
              tf.summary.scalar("g_loss", g_loss)
  
      return loss
  
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 24 for calling the HiFiC obj's underlying member method code with example usage: obj._create_gan_loss(d_out, create_summaries, mode) and returns: loss