code: def do_activation(cfg):
      if isinstance(cfg, CfgNode):
          data_loader = build_detection_test_loader(
              cfg, cfg.DATASETS.TEST[0]
          )
          model = build_model(cfg)
          DetectionCheckpointer(model).load(cfg.MODEL.WEIGHTS)
      else:
          data_loader = instantiate(cfg.dataloader.test)
          model = instantiate(cfg.model)
          model.to(cfg.train.device)
          DetectionCheckpointer(model).load(cfg.train.init_checkpoint)
      model.eval()
  
      counts = Counter()
      total_activations = []
      for idx, data in zip(
          tqdm.trange(args.num_inputs), data_loader
      ):  # noqa
          count = activation_count_operators(model, data)
          counts += count
          total_activations.append(sum(count.values()))
      logger.info(
          "(Million) Activations for Each Type of Operators:\n"
          + str([(k, v / idx) for k, v in counts.items()])
      )
      logger.info(
          "Total (Million) Activations: {}±{}".format(
              np.mean(total_activations), np.std(total_activations)
          )
      )
  
file_path: detectron2/tools/analyze_model.py
imports: import logging
  import numpy
  from collections import Counter
  import tqdm
  from fvcore.nn import flop_count_table
  from detectron2.checkpoint import DetectionCheckpointer
  from detectron2.config import CfgNode, LazyConfig, get_cfg, instantiate
  from detectron2.data import build_detection_test_loader
  from detectron2.engine import default_argument_parser
  from detectron2.modeling import build_model
  from detectron2.utils.analysis import FlopCountAnalysis, activation_count_operators, parameter_count_table
  from detectron2.utils.logger import setup_logger
label_desc: Use image node_id 3 for calling a global function with example usage: do_activation(cfg) without return types