code: def loss_fun(logits, labels):
      """Add L2Loss to all the trainable variables.
  
      Add summary for "Loss" and "Loss/avg".
      Args:
        logits: Logits from inference().
        labels: Labels from distorted_inputs or inputs(). 1-D tensor
                of shape [batch_size]
        distillation: if set to True, use probabilities and not class labels to
                      compute softmax loss
  
      Returns:
        Loss tensor of type float.
      """
  
      # Calculate the cross entropy between labels and predictions
      labels = tf.cast(labels, tf.int64)
      cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(
          logits=logits, labels=labels, name="cross_entropy_per_example"
      )
  
      # Calculate the average cross entropy loss across the batch.
      cross_entropy_mean = tf.reduce_mean(
          cross_entropy, name="cross_entropy"
      )
  
      # Add to TF collection for losses
      tf.add_to_collection("losses", cross_entropy_mean)
  
      # The total loss is defined as the cross entropy loss plus all of the weight
      # decay terms (L2 loss).
      return tf.add_n(tf.get_collection("losses"), name="total_loss")
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from datetime import datetime
  import math
  import numpy
  from six.moves import xrange
  import tensorflow.compat.v1
  import time
  import utils
label_desc: Use image node_id 5 for calling a global function with example usage: loss_fun(logits, labels) and returns: tf