code: def generate_pb_with_dense_layer():
      from tensorflow import keras
      import tensorflow as tf
      from tensorflow.python.framework.convert_to_constants import (
          convert_variables_to_constants_v2,
      )
  
      def get_model():
          # Create a simple model.
          inputs = keras.Input(shape=(32,))
          outputs = keras.layers.Dense(1, use_bias=True)(inputs)
          model = keras.Model(inputs, outputs)
          model.compile(optimizer="adam", loss="mean_squared_error")
          return model
  
      model = get_model()
  
      test_input = np.random.random((128, 32))
      test_target = np.random.random((128, 1))
      model.fit(test_input, test_target)
  
      full_model = tf.function(lambda x: model(x))
      full_model = full_model.get_concrete_function(
          tf.TensorSpec(model.inputs[0].shape, model.inputs[0].dtype)
      )
      frozen_func = convert_variables_to_constants_v2(full_model)
      frozen_func.graph.as_graph_def()
      layers = [op.name for op in frozen_func.graph.get_operations()]
      print("-" * 60)
      print("Frozen model layers: ")
      for layer in layers:
          print(layer)
      print("-" * 60)
      print("Frozen model inputs: ")
      print(frozen_func.inputs)
      print("Frozen model outputs: ")
      print(frozen_func.outputs)
      # Save frozen graph to disk
      frozen_graph_filename = "frozen_graph"
      frozen_out_path = ""
      tf.io.write_graph(
          graph_or_graph_def=frozen_func.graph,
          logdir=frozen_out_path,
          name=f"{frozen_graph_filename}.pb",
          as_text=False,
      )
      # Save its text representation
      tf.io.write_graph(
          graph_or_graph_def=frozen_func.graph,
          logdir=frozen_out_path,
          name=f"{frozen_graph_filename}.pbtxt",
          as_text=True,
      )
  
label_desc: Use image node_id 1 for calling a global function with example usage: generate_pb_with_dense_layer() and returns: model