code: def test_freeze_and_convert_matmul_graph(backend):
      # testing : https://coremltools.readme.io/docs/tensorflow-1#export-as-frozen-graph-and-convert
      graph = tf.Graph()
      with graph.as_default():
          x = tf.placeholder(tf.float32, shape=[None, 20], name="input")
          W = tf.Variable(tf.truncated_normal([20, 10], stddev=0.1))
          b = tf.Variable(tf.ones([10]))
          y = tf.matmul(x, W) + b
          output_names = [y.op.name]
  
      from tensorflow.python.tools.freeze_graph import freeze_graph
  
      model_dir = tempfile.TemporaryDirectory()
      graph_def_file = os.path.join(model_dir.name, "tf_graph.pb")
      checkpoint_file = os.path.join(model_dir.name, "tf_model.ckpt")
      frozen_graph_file = os.path.join(model_dir.name, "tf_frozen.pb")
  
      with tf.Session(graph=graph) as sess:
          # initialize variables
          sess.run(tf.global_variables_initializer())
          # save graph definition somewhere
          tf.train.write_graph(
              sess.graph, model_dir.name, graph_def_file, as_text=False
          )
          # save the weights
          saver = tf.train.Saver()
          saver.save(sess, checkpoint_file)
  
          # take the graph definition and weights
          # and freeze into a single .pb frozen graph file
          freeze_graph(
              input_graph=graph_def_file,
              input_saver="",
              input_binary=True,
              input_checkpoint=checkpoint_file,
              output_node_names=",".join(output_names),
              restore_op_name="save/restore_all",
              filename_tensor_name="save/Const:0",
              output_graph=frozen_graph_file,
              clear_devices=True,
              initializer_nodes="",
          )
      print(
          "Tensorflow frozen graph saved at {}".format(
              frozen_graph_file
          )
      )
      ct.convert(frozen_graph_file, convert_to=backend[0])
  
imports: import itertools
  import os
  import tempfile
  import numpy
  import pytest
  import coremltools
  from coremltools._deps import _HAS_TF_1, _HAS_TF_2, MSG_TF1_NOT_FOUND
  from coremltools.converters.mil.testing_reqs import backends, compute_units
  from coremltools.converters.mil.testing_utils import assert_cast_ops_count, assert_input_dtype, assert_ops_in_mil_program, assert_output_dtype, assert_prog_input_type, assert_prog_output_type, assert_spec_input_image_type, assert_spec_output_image_type, get_op_types_in_program, verify_prediction
  from coremltools.proto import FeatureTypes_pb2
  from coremltools.test.api.test_api_examples import TestInputs
label_desc: Use image node_id 4 for calling the TestTensorFlow1ConverterExamples obj's underlying member method code with example usage: obj.test_freeze_and_convert_matmul_graph(backend) without return types