code: def init_paddle_inference_config(args):
      import paddle.inference as paddle_infer
  
      config = paddle_infer.Config(args.model_file, args.params_file)
      if hasattr(args, "precision"):
          if args.precision == "fp16" and args.use_tensorrt:
              precision = paddle_infer.PrecisionType.Half
          elif args.precision == "int8":
              precision = paddle_infer.PrecisionType.Int8
          else:
              precision = paddle_infer.PrecisionType.Float32
      else:
          precision = paddle_infer.PrecisionType.Float32
  
      if args.use_gpu:
          gpu_id = get_infer_gpuid()
          if gpu_id is None:
              raise ValueError(
                  "Not found GPU in current device. Please check your device or set args.use_gpu as False"
              )
          config.enable_use_gpu(args.gpu_mem, 0)
          if args.use_tensorrt:
              config.enable_tensorrt_engine(
                  precision_mode=precision,
                  max_batch_size=args.max_batch_size,
                  min_subgraph_size=args.min_subgraph_size,
              )
              # skip the minmum trt subgraph
              min_input_shape = {"x": [1, 3, 10, 10]}
              max_input_shape = {"x": [1, 3, 1000, 1000]}
              opt_input_shape = {"x": [1, 3, 112, 112]}
              config.set_trt_dynamic_shape_info(
                  min_input_shape, max_input_shape, opt_input_shape
              )
  
      else:
          config.disable_gpu()
          cpu_threads = (
              args.cpu_threads if hasattr(args, "cpu_threads") else 10
          )
          config.set_cpu_math_library_num_threads(cpu_threads)
          if args.enable_mkldnn:
              # cache 10 different shapes for mkldnn to avoid memory leak
              config.enable_mkldnn()
              config.set_mkldnn_cache_capacity(10)
              if args.precision == "fp16":
                  config.enable_mkldnn_bfloat16()
      return config
  
file_path: insightface/recognition/arcface_paddle/tools/inference.py
imports: import sys
  import os
  import cv2
  import time
  import json
  import argparse
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: init_paddle_inference_config(args) and returns: config