class_docstr: Generates model graph, each node is created from single or multiple jit trace nodes.
docstr: merge the adjacent nodes of the module. The difference between the
  _expand_module_node and _expand_non_prim_node is that, the _expand_non_prim_node
  only merge the prim:: nodes into the aten:: node, in contrast,the _expand_module_node
  will merge all adjacent nodes into a same nodepy group.
  
  Parameters
  ----------
  node : trace graph node
      The non-prim node to expand
  node_name : str
      specify the node_name for NodePyGroup
  unique_name : str
      unique_name for the NodePyGroup
  op_type : str
      specify the op_type for the NodePyGroup
  nodes : list of trace graph node
      All the trace graph nodes within the same scope as the non-prim node
  input_to_node : dict
      key: input name, value: a node that uses this input
  output_to_node : dict
      key: output name, value: a node that generates this output
  module_type : str
      can be 'module' or 'func'
  Returns
  -------
  node
      the expanded non-prim node
code: def _expand_module_node(
      self,
      node,
      node_name,
      unique_name,
      op_type,
      nodes,
      input_to_node,
      output_to_node,
      module_type,
  ):
      """
      merge the adjacent nodes of the module. The difference between the
      _expand_module_node and _expand_non_prim_node is that, the _expand_non_prim_node
      only merge the prim:: nodes into the aten:: node, in contrast,the _expand_module_node
      will merge all adjacent nodes into a same nodepy group.
  
      Parameters
      ----------
      node : trace graph node
          The non-prim node to expand
      node_name : str
          specify the node_name for NodePyGroup
      unique_name : str
          unique_name for the NodePyGroup
      op_type : str
          specify the op_type for the NodePyGroup
      nodes : list of trace graph node
          All the trace graph nodes within the same scope as the non-prim node
      input_to_node : dict
          key: input name, value: a node that uses this input
      output_to_node : dict
          key: output name, value: a node that generates this output
      module_type : str
          can be 'module' or 'func'
      Returns
      -------
      node
          the expanded non-prim node
  
      """
      _logger.debug("expand module node, node name: %s", node_name)
      self.global_count += 1
      if not op_type:
          op_type = node.kind()
      node_group = [node]
      inputs = set()
      outputs = set()
      node_queue = queue.Queue()
      node_queue.put(node)
      visited = {node}
      while not node_queue.empty():
          curr_node = node_queue.get()
          for _input in curr_node.inputs():
              if _input.node().kind() == CONSTANT_KIND:
                  continue
              input_name = _input.debugName()
              if input_name in output_to_node:
                  for predecessor_node in output_to_node[input_name]:
                      if predecessor_node in nodes:
                          if predecessor_node not in visited:
                              node_group.append(predecessor_node)
                              node_queue.put(predecessor_node)
                              visited.add(predecessor_node)
                      else:
                          inputs.add(input_name)
              else:
                  inputs.add(input_name)
          for _output in curr_node.outputs():
              if _output.node().kind() == CONSTANT_KIND:
                  continue
              output_name = _output.debugName()
              if output_name in input_to_node:
                  for successor_node in input_to_node[output_name]:
                      if successor_node in nodes:
                          if successor_node not in visited:
                              node_group.append(successor_node)
                              node_queue.put(successor_node)
                              visited.add(successor_node)
                      else:
                          outputs.add(output_name)
              else:
                  outputs.add(output_name)
  
      nodepy = NodePyGroup(
          node_name,
          unique_name,
          module_type,
          op_type,
          node_group,
          inputs=list(inputs),
          outputs=list(outputs),
      )
      return nodepy
  
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 3 for calling the TorchModuleGraph obj's underlying member method code with example usage: obj._expand_module_node(node, node_name, unique_name, op_type, nodes, input_to_node, output_to_node, module_type) and returns: nodepy