code: def generic_loss(
      top_out, targets, model_hparams, vocab_size, weights_fn
  ):
      """Compute loss numerator and denominator for one shard of output."""
      del vocab_size  # unused arg
      logits = top_out
      logits = common_attention.maybe_upcast(
          logits, hparams=model_hparams
      )
      cutoff = getattr(model_hparams, "video_modality_loss_cutoff", 0.0)
      return common_layers.padded_cross_entropy(
          logits,
          targets,
          model_hparams.label_smoothing,
          cutoff=cutoff,
          weights_fn=weights_fn,
          reduce_sum=False,
      )
  
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 22 for calling a global function with example usage: generic_loss(top_out, targets, model_hparams, vocab_size, weights_fn) and returns: common_layers