code: def moving_av(total_loss):
      """
      Generates moving average for all losses
  
      Args:
        total_loss: Total loss from loss().
      Returns:
        loss_averages_op: op for generating moving averages of losses.
      """
      # Compute the moving average of all individual losses and the total loss.
      loss_averages = tf.train.ExponentialMovingAverage(0.9, name="avg")
      losses = tf.get_collection("losses")
      loss_averages_op = loss_averages.apply(losses + [total_loss])
  
      return loss_averages_op
  
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 6 for calling a global function with example usage: moving_av(total_loss) and returns: loss_averages_op