code: def get_train_op(loss, optimizer, grad_clip=None, global_step=None):
      """Make a train_op apply gradients to loss using optimizer.
  
      Args:
       loss: the loss function to optimize
       optimizer: the optimizer to compute and apply gradients
       grad_clip: clip gradient norms by the value supplied (default dont clip)
       global_step: tf.placeholder for global_step
  
      Returns:
       train_op: the training op to run
       grads_and_vars: the gradients and variables for debugging
       var_names: the variable names for debugging
       capped_grads_and_vars: for debugging
      """
      variables = tf.trainable_variables()
      grads_and_vars = optimizer.compute_gradients(loss, variables)
      var_names = [v.name for v in variables]
      logging.info("Trainable variables:")
      for var in var_names:
          logging.info("\t %s", var)
      logging.debug(grads_and_vars)
      grad_var_norms = [
          (tf.global_norm([gv[1]]), tf.global_norm([gv[0]]))
          for gv in grads_and_vars
      ]
  
      if grad_clip:
          capped_grads_and_vars = [
              (tf.clip_by_norm(gv[0], grad_clip), gv[1])
              for gv in grads_and_vars
          ]
      else:
          capped_grads_and_vars = grads_and_vars
      # norms of gradients for debugging
      # grad_norms = [tf.sqrt(tf.reduce_sum(tf.square(grad)))
      #               for grad, _ in grads_and_vars]
      train_op = optimizer.apply_gradients(
          capped_grads_and_vars, global_step=global_step
      )
      return train_op, grad_var_norms, var_names, capped_grads_and_vars
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gc
  import math
  import os
  from absl import app
  from absl import flags
  from absl import logging
  import clueweb_text_graph
  import dataset
  import graph
  import losses
  import metrics
  import models
  import numpy
  import slim
  from tensorboard.plugins import projector
  import tensorflow
  from tensorflow.python.training.summary_io import SummaryWriterCache
  import text_graph
  import utils
label_desc: Use image node_id 2 for calling a global function with example usage: get_train_op(loss, optimizer, grad_clip, global_step) and returns: train_op,  grad_var_norms,  var_names,  capped_grads_and_vars