docstr: Overwrites TFLoader._graph_def_from_model()
docstr_tok: ["Overwrites","TFLoader._graph_def_from_model","(",")"]
code: def _graph_def_from_model(self, outputs=None):
      """Overwrites TFLoader._graph_def_from_model()"""
      msg = "Expected model format: [tf.Graph | .pb | SavedModel | tf.keras.Model | .h5], got {}"
      if isinstance(self.model, tf.Graph) and hasattr(
          self.model, "as_graph_def"
      ):
          graph_def = self.model.as_graph_def(add_shapes=True)
          return self.extract_sub_graph(graph_def, outputs)
      elif isinstance(self.model, tf.keras.Model):
          graph_def = self._from_tf_keras_model(self.model)
          return self.extract_sub_graph(graph_def, outputs)
      elif isinstance(self.model, six.string_types):
          if not os.path.exists(str(self.model)):
              raise ValueError(
                  'Input model "{}" does not exist'.format(self.model)
              )
          elif os.path.isfile(str(self.model)) and self.model.endswith(
              ".pb"
          ):
              if tf.__version__ < _StrictVersion("1.13.1"):
                  with open(self.model, "rb") as f:
                      gd = tf.GraphDef()
                      gd.ParseFromString(f.read())
                  with tf.Graph().as_default() as graph:
                      tf.import_graph_def(gd, name="")
              else:
                  with tf.io.gfile.GFile(self.model, "rb") as f:
                      gd = tf.compat.v1.GraphDef()
                      gd.ParseFromString(f.read())
                  with tf.Graph().as_default() as graph:
                      tf.graph_util.import_graph_def(gd, name="")
              graph_def = graph.as_graph_def(add_shapes=True)
              return self.extract_sub_graph(graph_def, outputs)
          elif os.path.isfile(str(self.model)) and self.model.endswith(
              ".h5"
          ):
              graph_def = self._from_tf_keras_model(self.model)
              return self.extract_sub_graph(graph_def, outputs)
          elif os.path.isdir(str(self.model)):
              graph_def = self._from_saved_model(self.model)
              return self.extract_sub_graph(graph_def, outputs)
          else:
              raise NotImplementedError(msg.format(self.model))
      else:
          raise NotImplementedError(msg.format(self.model))
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import logging
  import os
  import gc
  import six
  import tensorflow
  from tempfile import mktemp
  from .basic_graph_ops import fill_outputs
  from .converter import TFConverter
  from .tf_graph_pass import *
  from .tfssa import NetworkEnsemble, SSAFunction
  from .parsed_tf_node import ParsedTFNode
  from coremltools.converters._profile_utils import _profile
  from tqdm import tqdm
  from distutils.version import StrictVersion
label_desc: Use image node_id 2 for calling the TF1Loader obj's underlying member method code with example usage: obj._graph_def_from_model(outputs) and returns: self, self, self, self, self