code: def get_flops(cfg, input_shape):
      model = build_detector(
          cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg
      )
      # if torch.cuda.is_available():
      #    model.cuda()
      model.eval()
      if hasattr(model, "forward_dummy"):
          model.forward = model.forward_dummy
      else:
          raise NotImplementedError(
              "FLOPs counter is currently not currently supported with {}".format(
                  model.__class__.__name__
              )
          )
      buf = io.StringIO()
      all_flops, params = get_model_complexity_info(
          model,
          input_shape,
          print_per_layer_stat=True,
          as_strings=False,
          ost=buf,
      )
      buf = buf.getvalue()
      # print(buf)
      lines = buf.split("\n")
      names = [
          "(stem)",
          "(layer1)",
          "(layer2)",
          "(layer3)",
          "(layer4)",
          "(neck)",
          "(bbox_head)",
      ]
      name_ptr = 0
      line_num = 0
      _flops = []
      while name_ptr < len(names):
          line = lines[line_num].strip()
          name = names[name_ptr]
          if line.startswith(name):
              flops = float(
                  lines[line_num + 1]
                  .split(",")[2]
                  .strip()
                  .split(" ")[0]
              )
              _flops.append(flops)
              name_ptr += 1
          line_num += 1
  
      backbone_flops = np.array(_flops[:-2], dtype=np.float32)
      neck_flops = _flops[-2]
      head_flops = _flops[-1]
  
      return all_flops / 1e9, backbone_flops, neck_flops, head_flops
  
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 3 for calling a global function with example usage: get_flops(cfg, input_shape) and returns: unknown,  backbone_flops,  neck_flops,  head_flops