code: def format_ops(ops, sort_outputs=True):
      """Helper method for printing ops. Converts Tensor/Operation op to op.name,
      rest to str(op)."""
  
      if hasattr(ops, "__iter__") and not isinstance(ops, str):
          l = [
              (op.name if hasattr(op, "name") else str(op))
              for op in ops
          ]
          if sort_outputs:
              return sorted(l)
          return l
      else:
          return ops.name if hasattr(ops, "name") else str(ops)
  
file_path: gpt-2-simple/gpt_2_simple/src/memory_saving_gradients.py
imports: from toposort import toposort
  import contextlib
  import numpy
  import tensorflow
  import time
  import sys
  from tensorflow.python.ops import gradients
label_desc: Use image node_id 12 for calling a global function with example usage: format_ops(ops, sort_outputs) and returns: l, unknown, sorted