code: def _from_saved_model(saved_model_dir):
      # must import here as tf.contrib is only available on TF 1.x
      from tensorflow.contrib.saved_model.python.saved_model import (
          reader,
      )
      from tensorflow.python.tools import freeze_graph
  
      saved_model_tags = reader.get_saved_model_tag_sets(
          saved_model_dir
      )[0]
      if not saved_model_tags:
          msg = "Unsupported SavedModel directory format: no tag_sets available"
          raise NotImplementedError(msg)
  
      # get model outputs
      output_node_names = []
      if _get_version(tf.__version__) < _StrictVersion("1.13.1"):
          sess = tf.Session()
      else:
          sess = tf.compat.v1.Session()
      metagraph = tf.saved_model.loader.load(
          sess, saved_model_tags, saved_model_dir
      )
      for sd in metagraph.signature_def.values():
          output_node_names += [
              o.name.split(":")[0] for o in sd.outputs.values()
          ]
  
      sess.close()
  
      # get frozen graph
      output_graph = mktemp()
      tf.compat.v1.reset_default_graph() if _get_version(
          tf.__version__
      ) >= _StrictVersion("1.13.1") else tf.reset_default_graph()
      freeze_graph.freeze_graph(
          input_graph=None,
          input_saver=None,
          input_binary=None,
          input_checkpoint=None,
          output_node_names=",".join(output_node_names),
          restore_op_name=None,
          filename_tensor_name=None,
          output_graph=output_graph,
          clear_devices=True,
          initializer_nodes="",
          variable_names_whitelist="",
          variable_names_blacklist="",
          input_meta_graph=None,
          input_saved_model_dir=saved_model_dir,
          saved_model_tags=",".join(saved_model_tags),
      )
  
      if _get_version(tf.__version__) < _StrictVersion("1.13.1"):
          graph_def = tf.GraphDef()
          with open(output_graph, "rb") as f:
              graph_def.ParseFromString(f.read())
          graph_def = tf.graph_util.remove_training_nodes(graph_def)
      else:
          graph_def = tf.compat.v1.GraphDef()
          with open(output_graph, "rb") as f:
              graph_def.ParseFromString(f.read())
          graph_def = tf.compat.v1.graph_util.remove_training_nodes(
              graph_def
          )
      with tf.Graph().as_default() as graph:
          tf.graph_util.import_graph_def(graph_def, name="")
      return graph.as_graph_def(add_shapes=True)
  
imports: import gc
  import os
  from distutils.version import StrictVersion
  from tempfile import mktemp
  import tensorflow
  from tqdm import tqdm
  from coremltools import _logger
  from coremltools._deps import _get_version
  from coremltools.converters._profile_utils import _profile
  from .._utils import get_output_names
  from .basic_graph_ops import fill_outputs
  from .converter import TFConverter
  from .parsed_tf_node import ParsedTFNode
  from .tf_graph_pass import cond_to_where, constant_propagation, delete_asserts, delete_disconnected_nodes, delete_unnecessary_constant_nodes, functionalize_loops, fuse_dilation_conv, insert_get_tuple, quantization_pass, remove_variable_nodes, tensor_array_resource_removal
  from .tfssa import NetworkEnsemble, SSAFunction
label_desc: Use image node_id 5 for calling the TF1Loader obj's underlying member method code with example usage: obj._from_saved_model(saved_model_dir) and returns: graph