code: def main():
      FLAGS = ArgsParser().parse_args()
      config = load_config(FLAGS.config)
      config = merge_config(config, FLAGS.opt)
      logger = get_logger()
      # build post process
  
      post_process_class = build_post_process(
          config["PostProcess"], config["Global"]
      )
  
      # build model
      # for rec algorithm
      if hasattr(post_process_class, "character"):
          char_num = len(getattr(post_process_class, "character"))
          if config["Architecture"]["algorithm"] in [
              "Distillation",
          ]:  # distillation model
              for key in config["Architecture"]["Models"]:
                  if (
                      config["Architecture"]["Models"][key]["Head"][
                          "name"
                      ]
                      == "MultiHead"
                  ):  # multi head
                      out_channels_list = {}
                      if (
                          config["PostProcess"]["name"]
                          == "DistillationSARLabelDecode"
                      ):
                          char_num = char_num - 2
                      if (
                          config["PostProcess"]["name"]
                          == "DistillationNRTRLabelDecode"
                      ):
                          char_num = char_num - 3
                      out_channels_list["CTCLabelDecode"] = char_num
                      out_channels_list["SARLabelDecode"] = char_num + 2
                      out_channels_list["NRTRLabelDecode"] = (
                          char_num + 3
                      )
                      config["Architecture"]["Models"][key]["Head"][
                          "out_channels_list"
                      ] = out_channels_list
                  else:
                      config["Architecture"]["Models"][key]["Head"][
                          "out_channels"
                      ] = char_num
                  # just one final tensor needs to exported for inference
                  config["Architecture"]["Models"][key][
                      "return_all_feats"
                  ] = False
          elif (
              config["Architecture"]["Head"]["name"] == "MultiHead"
          ):  # multi head
              out_channels_list = {}
              char_num = len(getattr(post_process_class, "character"))
              if config["PostProcess"]["name"] == "SARLabelDecode":
                  char_num = char_num - 2
              if config["PostProcess"]["name"] == "NRTRLabelDecode":
                  char_num = char_num - 3
              out_channels_list["CTCLabelDecode"] = char_num
              out_channels_list["SARLabelDecode"] = char_num + 2
              out_channels_list["NRTRLabelDecode"] = char_num + 3
              config["Architecture"]["Head"][
                  "out_channels_list"
              ] = out_channels_list
          else:  # base rec model
              config["Architecture"]["Head"]["out_channels"] = char_num
  
      # for sr algorithm
      if config["Architecture"]["model_type"] == "sr":
          config["Architecture"]["Transform"]["infer_mode"] = True
      model = build_model(config["Architecture"])
      load_model(
          config, model, model_type=config["Architecture"]["model_type"]
      )
      model.eval()
  
      save_path = config["Global"]["save_inference_dir"]
  
      arch_config = config["Architecture"]
  
      if (
          arch_config["algorithm"] == "SVTR"
          and arch_config["Head"]["name"] != "MultiHead"
      ):
          input_shape = config["Eval"]["dataset"]["transforms"][-2][
              "SVTRRecResizeImg"
          ]["image_shape"]
      else:
          input_shape = None
  
      if arch_config["algorithm"] in [
          "Distillation",
      ]:  # distillation model
          archs = list(arch_config["Models"].values())
          for idx, name in enumerate(model.model_name_list):
              sub_model_save_path = os.path.join(
                  save_path, name, "inference"
              )
              export_single_model(
                  model.model_list[idx],
                  archs[idx],
                  sub_model_save_path,
                  logger,
              )
      else:
          save_path = os.path.join(save_path, "inference")
          export_single_model(
              model,
              arch_config,
              save_path,
              logger,
              input_shape=input_shape,
          )
  
file_path: PaddleOCR/tools/export_model.py
imports: import os
  import sys
  import argparse
  import paddle
  from paddle.jit import to_static
  from ppocr.modeling.architectures import build_model
  from ppocr.postprocess import build_post_process
  from ppocr.utils.save_load import load_model
  from ppocr.utils.logging import get_logger
  from tools.program import load_config, merge_config, ArgsParser
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types