code: def __init__(self, model=None):
      self.flop_counts = defaultdict(lambda: defaultdict(int))
      self.parents = ["Global"]
      # global mod
      if model is not None:
          for name, module in dict(model.named_children()).items():
              module.register_forward_pre_hook(self.enter_module(name))
              module.register_forward_hook(self.exit_module(name))
  
imports: import os
  from collections import defaultdict
  from numbers import Number
  from typing import Any, List
  import torch
  from torch.utils._python_dispatch import TorchDispatchMode
  from torch.utils._pytree import tree_map
  from torchvision.models._api import Weights
label_desc: Use image node_id 1 to create a new FlopCounterMode object from inherited base classes: TorchDispatchMode with example: obj = FlopCounterMode(model)