code: def _count_layer_stats(layer, counters, level, res):
      info = OrderedDict()
      info["Layer Name"] = layer.full_name()
      info["Level"] = level
      children = list(layer.children())
      if len(children) > 0:
          children_names = set(m.full_name() for m in children)
          res_of_layer = []
          for child in children:
              res_of_layer = _count_layer_stats(
                  child, counters, level + 1, res_of_layer
              )
          for name in counters.keys():
              info[name] = sum(
                  item[name]
                  for item in res_of_layer
                  if item["Layer Name"] in children_names
              )
          res.append(info)
          res.extend(res_of_layer)
      else:
          # XXX: Hard-code default items
          if hasattr(layer, "input_shape"):
              info["Input Shape"] = layer.input_shape.numpy().tolist()
          if hasattr(layer, "output_shape"):
              info["Output Shape"] = layer.output_shape.numpy().tolist()
          for name, cnter in counters.items():
              info[name] = cnter(layer)
          res.append(info)
      return res
  
file_path: PaddleSeg/contrib/PanopticSeg/tools/analyze_model.py
imports: import argparse
  import io
  import sys
  import contextlib
  from collections import OrderedDict
  import paddle
  from paddle.hapi.static_flops import Table
  from paddle.hapi.dynamic_flops import count_parameters, register_hooks, count_io_info
  from paddleseg.utils import get_sys_env, logger, op_flops_funs, utils
  from paddlepanseg.cvlibs import Config, make_default_builder
label_desc: Use image node_id 3 for calling a global function with example usage: _count_layer_stats(layer, counters, level, res) and returns: res