code: def apply_leaf(m, f):
      c = m if isinstance(m, (list, tuple)) else list(m.children())
      if isinstance(m, nn.Module):
          f(m)
      if len(c) > 0:
          for l in c:
              apply_leaf(l, f)
  
imports: import torch
  import logging
  import torch.nn
  import torch.nn.functional
  from torchvision import models
  from itertools import chain
  import numpy
  from collections import OrderedDict
label_desc: Use image node_id 3 for calling a global function with example usage: apply_leaf(m, f) without return types