code: def _for_leaf(model, fn, *args):
      for name, module in model.named_modules():
          if len(list(module.children())) == 0:
              fn(name, module, *args)
  
imports: import time
  from collections import OrderedDict
  from typing import Dict, Sequence
  import functools
  import itertools
  import numpy
  import torch
  import torch.nn
  from .compute_madd import compute_madd
  from .compute_flops import compute_flops
  from .compute_memory import compute_memory
  from .stat_tree import StatTree, StatNode
  from .reporter import report_format
label_desc: Use image node_id 3 for calling a global function with example usage: _for_leaf(model, fn) without return types