class_docstr: Args:
      model_dir (str): root path of model.pdiparams, model.pdmodel and infer_cfg.yml
      device (str): Choose the device you want to run, it can be: CPU/GPU/XPU/NPU, default is CPU
      run_mode (str): mode of running(paddle/trt_fp32/trt_fp16)
      batch_size (int): size of pre batch in inference
      trt_min_shape (int): min shape for dynamic shape in trt
      trt_max_shape (int): max shape for dynamic shape in trt
      trt_opt_shape (int): opt shape for dynamic shape in trt
      trt_calib_mode (bool): If the model is produced by TRT offline quantitative
          calibration, trt_calib_mode need to set True
      cpu_threads (int): cpu threads
      enable_mkldnn (bool): whether to open MKLDNN
      threshold (float): The threshold of score for action feature object detection.
      display_frames (int): The duration for corresponding detected action.
      skip_frame_num (int): The number of frames for interval prediction. A skipped frame will 
          reuse the result of its last frame. If it is set to 0, no frame will be skipped. Default
          is 0.
class_docstr_tok: ["Args",":","model_dir","(","str",")",":","root","path","of","model.pdiparams",",","model.pdmodel","and","infer_cfg.yml","device","(","str",")",":","Choose","the","device","you","want","to","run",",","it","can","be",":","CPU\/GPU\/XPU\/NPU",",","default","is","CPU","run_mode","(","str",")",":","mode","of","running","(","paddle\/trt_fp32\/trt_fp16",")","batch_size","(","int",")",":","size","of","pre","batch","in","inference","trt_min_shape","(","int",")",":","min","shape","for","dynamic","shape","in","trt","trt_max_shape","(","int",")",":","max","shape","for","dynamic","shape","in","trt","trt_opt_shape","(","int",")",":","opt","shape","for","dynamic","shape","in","trt","trt_calib_mode","(","bool",")",":","If","the","model","is","produced","by","TRT","offline","quantitative","calibration",",","trt_calib_mode","need","to","set","True","cpu_threads","(","int",")",":","cpu","threads","enable_mkldnn","(","bool",")",":","whether","to","open","MKLDNN","threshold","(","float",")",":","The","threshold","of","score","for","action","feature","object","detection",".","display_frames","(","int",")",":","The","duration","for","corresponding","detected","action",".","skip_frame_num","(","int",")",":","The","number","of","frames","for","interval","prediction",".","A","skipped","frame","will","reuse","the","result","of","its","last","frame",".","If","it","is","set","to","0",",","no","frame","will","be","skipped",".","Default","is","0","."]
code: def init_with_cfg(cls, args, cfg):
      return cls(
          model_dir=cfg["model_dir"],
          batch_size=cfg["batch_size"],
          threshold=cfg["threshold"],
          display_frames=cfg["display_frames"],
          skip_frame_num=cfg["skip_frame_num"],
          device=args.device,
          run_mode=args.run_mode,
          trt_min_shape=args.trt_min_shape,
          trt_max_shape=args.trt_max_shape,
          trt_opt_shape=args.trt_opt_shape,
          trt_calib_mode=args.trt_calib_mode,
          cpu_threads=args.cpu_threads,
          enable_mkldnn=args.enable_mkldnn,
      )
  
imports: import os
  import yaml
  import glob
  import cv2
  import numpy
  import math
  import paddle
  import sys
  from paddle.inference import Config, create_predictor
  from python.utils import argsparser, Timer, get_current_memory_mb
  from python.benchmark_utils import PaddleInferBenchmark
  from python.infer import Detector, print_arguments
  from attr_infer import AttrDetector
label_desc: Use image node_id 2 for calling the DetActionRecognizer obj's underlying member method code with example usage: obj.init_with_cfg(cls, args, cfg) and returns: cls