code: def main(args):
      paddle.enable_static()
      rank_id = paddle.distributed.get_rank()
  
      if args.devices == "gpu":
          place = paddle.CUDAPlace(rank_id)
          paddle.set_device("gpu")
      else:
          place = paddle.CPUPlace()
          paddle.set_device("cpu")
  
      # step1: load dataset config and create dataloader
      act_config = load_slim_config(args.act_config_path)
      assert os.path.exists(
          args.config_path
      ), f"config path does't exist: {args.config_path}"
  
      data_cfg = Config(args.config_path)
      builder = SegBuilder(data_cfg)
  
      train_dataset = builder.train_dataset
      global eval_dataset
      eval_dataset = builder.val_dataset
      batch_size = data_cfg.batch_size
  
      batch_sampler = paddle.io.DistributedBatchSampler(
          train_dataset,
          batch_size=batch_size,
          shuffle=True,
          drop_last=True,
      )
      train_loader = paddle.io.DataLoader(
          train_dataset,
          places=[place],
          batch_sampler=batch_sampler,
          num_workers=0,
          return_list=True,
          worker_init_fn=worker_init_fn,
      )
  
      input_name = get_feed_vars(
          act_config["Global"]["model_dir"],
          act_config["Global"]["model_filename"],
          act_config["Global"]["params_filename"],
      )  # get the name of forward input
      train_dataloader = reader_wrapper(train_loader, input_name)
  
      # step2: create and instance of AutoCompression
      ac = AutoCompression(
          model_dir=act_config["Global"]["model_dir"],
          model_filename=act_config["Global"]["model_filename"],
          params_filename=act_config["Global"]["params_filename"],
          save_dir=args.save_dir,
          config=act_config,
          train_dataloader=train_dataloader,
          eval_callback=eval_function if rank_id == 0 else None,
          deploy_hardware=act_config["Global"].get("deploy_hardware")
          or None,
          input_shapes=act_config["Global"].get("input_shapes", None),
      )
  
      # step3: start the compression job
      ac.compress()
  
file_path: PaddleSeg/deploy/slim/act/run_seg.py
imports: import os
  import argparse
  import random
  import paddle
  import numpy
  from paddleseg.cvlibs import Config
  from paddleseg.cvlibs import SegBuilder
  from paddleseg.utils import worker_init_fn, metrics
  from paddleseg.core.infer import reverse_transform
  from paddleslim.auto_compression import AutoCompression
  from paddleslim.common import load_config
  from paddleslim.common.dataloader import get_feed_vars
label_desc: Use image node_id 4 for calling a global function with example usage: main(args) without return types