class_docstr: Models a perception module inference graph.
          Conditions on using the InferenceGraph object:
              1. All keys of the perception_blocks dictionary have to be unique
              2. All out_keys used when creating the blocks have to be unique
              3. All out_keys of a given block have to be sub-strings of the blocks key in the perception_blocks dict
  
  :param inference_block: An inference perception block to build the graph for.
class_docstr_tok: ["Models","a","perception","module","inference","graph",".","Conditions","on","using","the","InferenceGraph","object",":","1",".","All","keys","of","the","perception_blocks","dictionary","have","to","be","unique","2",".","All","out_keys","used","when","creating","the","blocks","have","to","be","unique","3",".","All","out_keys","of","a","given","block","have","to","be","sub-strings","of","the","blocks","key","in","the","perception_blocks","dict",":","param","inference_block",":","An","inference","perception","block","to","build","the","graph","for","."]
docstr: Add a node representing a perception block to the graph with the correct label
  
  :param block_key: The block the label should be generated for
  :return: The current blocks and the corresponding block id
docstr_tok: ["Add","a","node","representing","a","perception","block","to","the","graph","with","the","correct","label",":","param","block_key",":","The","block","the","label","should","be","generated","for",":","return",":","The","current","blocks","and","the","corresponding","block","id"]
code: def _add_node_to_node_graph(
      self, block_key: str
  ) -> Tuple[nn.Module, str]:
      """Add a node representing a perception block to the graph with the correct label
  
      :param block_key: The block the label should be generated for
      :return: The current blocks and the corresponding block id
      """
  
      curr_block = self.perception_blocks[block_key]
      block_id = "{}\n({})".format(
          curr_block.__class__.__name__, block_key
      )
      num_of_block_params = sum(
          pp.numel() for pp in curr_block.parameters()
      )
  
      label = str(curr_block).replace("\t", "")
      if num_of_block_params > 0:
          label += f"\n#{num_of_block_params:,} = {num_of_block_params / self._total_num_of_params * 100:.1f}%"
  
      self.node_graph.add_node(
          block_id,
          label=label,
          is_block=True,
          num_params=num_of_block_params,
          block_id=block_key,
      )
      return curr_block, block_id
  
imports: import os
  import pickle
  from typing import Union, List, Dict, Optional, Sequence, Tuple
  import networkx
  import torch
  from matplotlib import pyplot
  from torch import nn
  from maze.core.annotations import override
  from maze.perception.blocks.base import PerceptionBlock
label_desc: Use image node_id 8 for calling the InferenceGraph obj's underlying member method code with example usage: obj._add_node_to_node_graph(block_key) and returns: curr_block,  block_id