code: def _get_train_op(loss, train_op_fn=None, optimizer=None):
      """Returns a train op."""
      if optimizer is not None:
          if train_op_fn is not None:
              raise ValueError(
                  "train_op_fn and optimizer cannot both be set."
              )
          train_op = optimizer.minimize(
              loss, global_step=tf.compat.v1.train.get_global_step()
          )
      elif train_op_fn is not None:
          train_op = train_op_fn(loss)
      else:
          raise ValueError(
              "train_op_fn and optimizer cannot both be None."
          )
      return train_op
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import six
  import tensorflow
  from tensorflow import estimator
label_desc: Use image node_id 3 for calling a global function with example usage: _get_train_op(loss, train_op_fn, optimizer) and returns: train_op