code: def model_loader(filename: str) -> lite.TFLiteConverter:
      """Load TF ProtoBuf (for TF v1 and v2)
  
      Args:
          filename (str): ProtoBuf file name
  
      Returns:
          lite.TFLiteConverter: TFLite converter
      """
      input_names = FLAGS.input_nodes.split(",")
      output_names = FLAGS.output_nodes.split(",")
  
      # Overwrite default input_shape with user defined input_shape
      if FLAGS.input_shape is not None:
          shapes = []
          input_shapes = FLAGS.input_shape.split(";")
          for input_shape in input_shapes:
              shape = [int(x) for x in input_shape.split(",")]
              shapes.append(shape)
  
      if tf.__version__[0] == "2":  # pylint: disable=no-member
          # require frozen pb
          logger.info("Tensorflow version 2.x")
          g = tf.Graph()
          graph_def = pb.load_graphdef(filename)
          if verify_input_names(
              [i.split(":")[0] for i in input_names], graph_def
          ):
              logger.info("Correct input names")
          else:
              raise Exception("Wrong input nodes")
          if verify_output_names(
              [i.split(":")[0] for i in output_names], graph_def
          ):
              logger.info("Correct output names")
          else:
              raise Exception("Wrong output nodes")
          # get input shapes
          if not FLAGS.input_shape:
              shapes = [
                  find_node_shape(name, graph_def)
                  for name in input_names
              ]
          else:
              shapes = [shape[1:] for shape in shapes]
  
          # import protobuf and create Keras model
          with g.as_default():
              inputs = {}
              for name, shape in zip(input_names, shapes):
                  inputs[name] = keras.layers.Input(
                      shape=shape, name="input"
                  )
              tf.import_graph_def(graph_def, name="", input_map=inputs)
              tf_outputs = [
                  g.get_tensor_by_name(name) for name in output_names
              ]
              model = keras.Model(inputs=inputs, outputs=tf_outputs)
          return lite.TFLiteConverter.from_keras_model(model)
      else:
          logger.info("Tensorflow version 1.x")
          input_names = [i.split(":")[0] for i in input_names]
          output_names = [i.split(":")[0] for i in output_names]
          try:
              tflite_model = lite.TFLiteConverter.from_frozen_graph(
                  filename, input_names, output_names
              )
          except Exception as e:
              graph_def = pb.load_graphdef(filename)
              if verify_input_names(input_names, graph_def):
                  logger.info("Correct input names")
              if verify_output_names(output_names, graph_def):
                  logger.info("Correct output names")
              raise e
          return tflite_model
  
file_path: auptimizer/src/aup/dlconvert/pb_to_tflite.py
imports: from os import path
  import logging
  from typing import List
  from absl import flags, app
  from tensorflow import lite, keras
  import tensorflow
  from .utils import reset_flag
  from .to_tflite import create_converter
  from .spec_utils import pb
label_desc: Use image node_id 4 for calling a global function with example usage: model_loader(filename) and returns: lite, tflite_model