code: def load_metadata(model_dir):
      """Loads RunMetadata, Graph and OpLog from files"""
      # Import RunMetadata
      run_meta_path = os.path.join(model_dir, "metadata/run_meta")
      run_meta = tf.RunMetadata()
      if gfile.Exists(run_meta_path):
          with gfile.GFile(run_meta_path, "rb") as file:
              run_meta.MergeFromString(file.read())
          print("Loaded RunMetadata from {}".format(run_meta_path))
      else:
          print(
              "RunMetadata does not exist a {}. Skipping.".format(
                  run_meta_path
              )
          )
  
      # Import Graph
      graph_def_path = os.path.join(model_dir, "graph.pbtxt")
      graph = tf.Graph()
      if gfile.Exists(graph_def_path):
          with graph.as_default():
              _register_function_ops(CUSTOM_OP_FUNCTIONS)
              graph_def = tf.GraphDef()
              with gfile.GFile(graph_def_path, "rb") as file:
                  text_format.Parse(file.read(), graph_def)
              tf.import_graph_def(graph_def, name="")
              print("Loaded Graph from {}".format(graph_def_path))
      else:
          print(
              "Graph does not exist a {}. Skipping.".format(
                  graph_def_path
              )
          )
  
      # Import OpLog
      op_log_path = os.path.join(model_dir, "metadata/tfprof_log")
      op_log = tfprof_log_pb2.OpLog()
      if gfile.Exists(op_log_path):
          with gfile.GFile(op_log_path, "rb") as file:
              op_log.MergeFromString(file.read())
              print("Loaded OpLog from {}".format(op_log_path))
      else:
          print(
              "OpLog does not exist a {}. Skipping.".format(op_log_path)
          )
  
      return run_meta, graph, op_log
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import os
  import six
  from google.protobuf import text_format
  import tensorflow
  from tensorflow.contrib.tfprof import model_analyzer
  from tensorflow.contrib.tfprof.python.tools.tfprof import tfprof_logger
  from tensorflow import gfile
  from tensorflow.tools.tfprof import tfprof_log_pb2
  from tensorflow.python.framework import op_def_registry
  from tensorflow.python.framework.ops import RegisterShape
  from tensorflow.python.framework import common_shapes
  from seq2seq.decoders.attention import att_sum_bahdanau, att_sum_dot
label_desc: Use image node_id 2 for calling a global function with example usage: load_metadata(model_dir) and returns: run_meta,  graph,  op_log