code: def _get_step_for_v2():
      """Get step for v2 summary invocation in v1.
  
      In order to invoke v2 op in `tf.compat.v1.summary`, global step needs to be
      set for the v2 summary writer.
  
      Returns:
        The step set by `tf.summary.experimental.set_step` or
        `tf.compat.v1.train.create_global_step`, or None is no step has been
        set.
      """
      step = _summary_ops_v2.get_step()
      if step is not None:
          return step
      return _training_util.get_global_step()
  
imports: import contextlib
  import warnings
  from google.protobuf import json_format
  from tensorflow.core.framework.summary_pb2 import Summary
  from tensorflow.core.framework.summary_pb2 import SummaryDescription
  from tensorflow.core.framework.summary_pb2 import SummaryMetadata
  from tensorflow.core.util.event_pb2 import Event
  from tensorflow.core.util.event_pb2 import SessionLog
  from tensorflow.core.util.event_pb2 import TaggedRunMetadata
  from tensorflow.python.distribute import summary_op_util
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_logging_ops
  from tensorflow.python.ops import gen_summary_ops
  from tensorflow.python.ops import summary_op_util
  from tensorflow.python.ops import summary_ops_v2
  from tensorflow.python.summary import tb_summary
  from tensorflow.python.summary.writer.writer import FileWriter
  from tensorflow.python.summary.writer.writer_cache import FileWriterCache
  from tensorflow.python.training import training_util
  from tensorflow.python.util import compat
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 10 for calling a global function with example usage: _get_step_for_v2() and returns: _training_util, step