class_docstr: Generates model graph, each node is created from single or multiple jit trace nodes.
docstr: Extract leaf modules from the given graph. Leaf module means it does not have submodules.
  To extract leaf modules because only leaf module can be replaced. And shape inference can
  be done in leaf module level. Other shape inference is done in lower level i.e.,
  operation level.
  
  Returns
  -------
  list
      a list of scope name of all the leaf modules
code: def _extract_leaf_modules(self):
      """
      Extract leaf modules from the given graph. Leaf module means it does not have submodules.
      To extract leaf modules because only leaf module can be replaced. And shape inference can
      be done in leaf module level. Other shape inference is done in lower level i.e.,
      operation level.
  
      Returns
      -------
      list
          a list of scope name of all the leaf modules
      """
  
      def is_parent(name1, name2):
          """
          check if name1 is parent node of name2, for example:
          name1: aa.bb,  name2: aa.bb.cc,  return True
          name1: aa.b,  name2: aa.bb, return False
          """
          parts1, parts2 = name1.split("."), name2.split(".")
          if len(parts1) >= len(parts2):
              return False
          for i, _ in enumerate(parts1):
              if parts2[i] != parts1[i]:
                  return False
          return True
  
      module_names = sorted(
          [x[0] for x in self.trace.named_modules() if x[0]]
      )
      leaf_nodes = []
      for i, name in enumerate(module_names):
          if i + 1 >= len(module_names) or not is_parent(
              name, module_names[i + 1]
          ):
              leaf_nodes.append(name)
      return leaf_nodes
  
imports: import logging
  import queue
  import re
  from collections import defaultdict
  import torch
  from torch.utils.tensorboard._pytorch_graph import NodePy, NodePyIO, NodePyOP, GraphPy
label_desc: Use image node_id 7 for calling the TorchModuleGraph obj's underlying member method code with example usage: obj._extract_leaf_modules() and returns: leaf_nodes, True, False, False