code: def main():
      args = get_args()
      print(datetime.datetime.now())
  
      input_shape = (3, 480, 640)
      runtime_input_shape = input_shape
      flops_mult = 1.0
  
      assert osp.exists(args.group)
      group_name = args.group.split("/")[-1]
      assert len(group_name) > 0
      input_template = osp.join(
          args.group, "%s_%d.py" % (group_name, args.template)
      )
      assert osp.exists(input_template)
      write_index = args.template + 1
      while True:
          output_cfg = osp.join(
              args.group, "%s_%d.py" % (group_name, write_index)
          )
          if not osp.exists(output_cfg):
              break
          write_index += 1
      print("write-index from:", write_index)
  
      if args.mode == 1:
          gen = GenConfigBackbone()
      elif args.mode == 2:
          gen = GenConfigAll()
          det_cfg = Config.fromfile(input_template)
          _, template_backbone_flops, _, _ = get_flops(
              det_cfg, runtime_input_shape
          )
          template_backbone_ratios = list(
              map(
                  lambda x: x / template_backbone_flops[0],
                  template_backbone_flops,
              )
          )
          print("template_backbone_ratios:", template_backbone_ratios)
  
      pp = 0
      write_count = 0
      while write_count < args.num_configs:
          pp += 1
          det_cfg = Config.fromfile(input_template)
          config = gen.rand
          det_cfg = config.merge_cfg(det_cfg)
          all_flops, backbone_flops, neck_flops, head_flops = get_flops(
              det_cfg, runtime_input_shape
          )
          assert len(backbone_flops) == 5
          all_flops *= flops_mult
          backbone_flops *= flops_mult
          neck_flops *= flops_mult
          head_flops *= flops_mult
          is_valid = True
          if pp % 10 == 0:
              print(
                  pp,
                  all_flops,
                  backbone_flops,
                  neck_flops,
                  head_flops,
                  datetime.datetime.now(),
              )
          if args.mode == 2:
              backbone_ratios = list(
                  map(lambda x: x / backbone_flops[0], backbone_flops)
              )
              # if head_flops*0.8<neck_flops:
              #    continue
              for i in range(1, 5):
                  if not is_flops_valid(
                      template_backbone_ratios[i],
                      backbone_ratios[i],
                      args.eps * 5,
                  ):
                      is_valid = False
                      break
          if not is_valid:
              continue
          # if args.mode==1:
          #    if np.argmax(backbone_flops)!=1:
          #        continue
          #    if np.mean(backbone_flops[1:3])*0.8<np.mean(backbone_flops[-2:]):
          #        continue
          if not is_flops_valid(all_flops, args.gflops, args.eps):
              continue
  
          output_cfg_file = osp.join(
              args.group, "%s_%d.py" % (group_name, write_index)
          )
          det_cfg.dump(output_cfg_file)
          print(
              "SUCC",
              write_index,
              all_flops,
              backbone_flops,
              neck_flops,
              head_flops,
              datetime.datetime.now(),
          )
          write_index += 1
          write_count += 1
  
imports: import os
  import os.path
  import io
  import numpy
  import argparse
  import datetime
  import importlib
  import configparser
  from tqdm import tqdm
  from mmdet.models import build_detector
  import torch
  import autotorch
  from mmcv import Config
  from mmdet.models import build_detector
label_desc: Use image node_id 5 for calling a global function with example usage: main() without return types