code: def collect_dynamic_shape(args):
      if not is_support_collecting():
          logger.error(
              "The Paddle does not support collecting dynamic shape, "
              "please reinstall the PaddlePaddle (latest gpu version)."
          )
  
      # prepare config
      cfg = DeployConfig(args.config)
      pred_cfg = PredictConfig(cfg.model, cfg.params)
      pred_cfg.enable_use_gpu(1000, 0)
      pred_cfg.collect_shape_range_info(args.dynamic_shape_path)
  
      # create predictor
      predictor = create_predictor(pred_cfg)
      input_names = predictor.get_input_names()
      input_handle = predictor.get_input_handle(input_names[0])
  
      # get images
      img_path_list, _ = get_image_list(args.image_path)
      if not isinstance(img_path_list, (list, tuple)):
          img_path_list = [img_path_list]
      logger.info(f"The num of images is {len(img_path_list)} \n")
  
      # collect
      progbar_val = progbar.Progbar(target=len(img_path_list))
      for idx, img_path in enumerate(img_path_list):
          data = {"img": img_path}
          data = np.array([cfg.transforms(data)["img"]])
          input_handle.reshape(data.shape)
          input_handle.copy_from_cpu(data)
  
          try:
              predictor.run()
          except:
              logger.info(
                  "Fail to collect dynamic shape. Usually, the error is out of "
                  "GPU memory, for the model and image are too large.\n"
              )
              del predictor
              if os.path.exists(args.dynamic_shape_path):
                  os.remove(args.dynamic_shape_path)
  
          progbar_val.update(idx + 1)
  
      logger.info(
          f"The dynamic shape is save in {args.dynamic_shape_path}"
      )
  
file_path: PaddleSeg/deploy/python/collect_dynamic_shape.py
imports: import argparse
  import os
  import numpy
  from paddle.inference import create_predictor
  from paddle.inference import Config
  from paddleseg.utils import logger, get_image_list, progbar
  from paddleseg.deploy.infer import DeployConfig
label_desc: Use image node_id 3 for calling a global function with example usage: collect_dynamic_shape(args) without return types