code: def save_log_loss(
      hparams,
      targets_mask,
      numerator,
      denominator,
      log_q_z,
      log_abs_det,
      log_p_z_base,
      z_q,
      lenpred_loss,
      targets_length_pred,
      targets_length,
  ):
      """Populate loss dictionary and summary."""
      anneal, kl_mask = get_anneal_mask(hparams)
      lenpred_acc, lenpred_acc5 = lenpred_stats(
          targets_length_pred, targets_length
      )
      batch_length = tf.reduce_sum(targets_mask)
  
      z_q_norm = gops.reduce_mean_over_bl(
          tf.norm(z_q, axis=2, keepdims=True), targets_mask
      )[0]
  
      log_q_z = gops.reduce_mean_over_bl_sum_over_c(
          log_q_z, targets_mask
      )
      log_p_z_base = tf.reduce_sum(log_p_z_base, axis=0) / batch_length
      log_abs_det = tf.reduce_sum(log_abs_det, axis=0) / batch_length
      log_p_z_reg = gops.standard_normal_density(
          z_q, targets_mask, reduce_sum=True
      )
  
      log_p_x = -1 * numerator / denominator
      log_p_z = log_p_z_base + log_abs_det
      kl = log_q_z - log_p_z
      kl_reg = log_p_z - log_p_z_reg
      elbo = log_p_x - kl
      monitor = {
          "elbo": elbo,
          "kl": kl,
          "kl_reg": kl_reg,
          "log_p_x": log_p_x,
          "log_q_z": log_q_z,
          "log_p_z": log_p_z,
          "log_p_z_base": log_p_z_base,
          "log_abs_det": log_abs_det,
          "anneal": anneal,
          "z_q_norm": z_q_norm,
          "lenpred_acc": lenpred_acc,
          "lenpred_acc5": lenpred_acc5,
      }
  
      kl = kl * anneal
      kl_reg = hparams.kl_reg * kl_reg * anneal
      loss_dict = {
          "training": -1 * log_p_x,
          "kl": kl * kl_mask,
          "kl_reg": kl_reg * kl_mask,
      }
      if lenpred_loss is not None:
          monitor["lenpred_loss"] = lenpred_loss
          loss_dict["lenpred_loss"] = lenpred_loss
      return loss_dict, monitor
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from six.moves import range
  from tensor2tensor.layers import common_attention
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import transformer_glow_layers_ops
  from tensor2tensor.models.transformer import transformer_decoder_layer
  from tensor2tensor.models.transformer import transformer_encoder
  from tensor2tensor.models.transformer import transformer_prepare_encoder
  from tensor2tensor.utils import learning_rate
  from tensor2tensor.utils import mlperf_log
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 14 for calling a global function with example usage: save_log_loss(hparams, targets_mask, numerator, denominator, log_q_z, log_abs_det, log_p_z_base, z_q, lenpred_loss, targets_length_pred, targets_length) and returns: loss_dict,  monitor