docstr: Set the permutation flags for each node based only on that node's module type and parameters
code: def init_permutation_flags(cls, fx_graph):
      """Set the permutation flags for each node based only on that node's module type and parameters"""
  
      if cls.__verbosity > 0:
          print(
              "\n[init_permutation_flags] Initialize the permutation flags for each node according to module type and parameters"
          )
  
      # initialize some graph-wide trackers
      cls.__group_data = {}
      cls.__group_data["next_sibling_group_id"] = 0
      cls.__group_data["next_coparent_group_id"] = 0
      cls.__group_data["sibling_groups"] = {}
      cls.__group_data["sibling_group_permutations"] = {}
      cls.__group_data["sibling_group_C_params"] = {}
      cls.__group_data["skipped_sibling_groups"] = {}
      cls.__group_data["coparent_groups"] = {}
      cls.__group_data["skipped_coparent_groups"] = {}
  
      # track MHA nodes
      MHA_nodes = []
  
      # initialize each node's details
      for node_name in fx_graph.keys():
          fx_node = fx_graph.get(node_name)
          node_module_type = fx_node.get("module_type")
          if cls.__verbosity > 1:
              if node_module_type == "get_attr":
                  print(
                      f"Initializing node {node_name} of type {node_module_type}"
                  )
              else:
                  print(
                      f"Initializing node {node_name} of type {node_module_type}: {fx_node}"
                  )
  
          # default for all nodes: don't allow anything
          if node_module_type is not None:
              fx_graph[node_name][
                  "C_permutable"
              ] = False  # does this node have parameters that can be permuted in C
              fx_graph[node_name][
                  "K_permutable"
              ] = False  # does this node have parameters that can be permuted in K
              fx_graph[node_name][
                  "K_passthru"
              ] = False  # does this node need to pass a K permutation to its parents
              fx_graph[node_name]["is_real"] = False
              fx_graph[node_name]["C_permuted"] = False
              fx_graph[node_name]["K_permuted"] = False
  
              # initialize sibling and coparent groups
              fx_graph[node_name]["sibling_group_id"] = None
              fx_graph[node_name]["coparent_group_id"] = None
  
              # update each node to be more permissive if supported
              if (
                  node_module_type
                  in cls.__permutation_target_module_types
              ):
                  fx_graph[node_name]["is_real"] = True
                  node_groups = fx_graph.get(node_name).get(
                      "groups_param"
                  )
  
                  if node_groups in [
                      "None",
                      "1",
                  ]:  # no groups, no constraints
                      fx_graph[node_name]["C_permutable"] = True
                      fx_graph[node_name]["K_permutable"] = True
  
                  else:  # handle groups
                      Permutation.init_grouped_conv_permutation_flags(
                          fx_graph,
                          node_name,
                          node_groups,
                          cls.__verbosity,
                      )
  
              elif (
                  node_module_type
                  in cls.__permute_K_and_passthru_module_types
              ):
                  fx_graph[node_name]["K_permutable"] = True
                  fx_graph[node_name]["K_passthru"] = True
                  fx_graph[node_name]["is_real"] = False
  
              elif (
                  node_module_type in cls.__simple_passthru_module_types
              ):
                  fx_graph[node_name]["K_passthru"] = True
                  fx_graph[node_name]["is_real"] = False
  
              elif (
                  node_module_type
                  in cls.__disallow_permutations_module_types
              ):
                  fx_graph[node_name]["is_real"] = True
                  fx_graph[node_name]["C_param"] = 1
                  fx_graph[node_name]["K_param"] = 1
                  fx_graph[node_name]["groups_param"] = 1
  
              elif "activation" in node_module_type:
                  if cls.__verbosity > 0:
                      print(
                          f"WARNING: how should permutation flags be initialized for node {node_name} of module type {node_module_type}?  Found 'activation', assuming simple passthru behavior."
                      )
                  fx_graph[node_name]["K_passthru"] = True
                  fx_graph[node_name]["is_real"] = False
  
              else:
                  if cls.__verbosity > 0:
                      print(
                          f"WARNING: how should permutation flags be initialized for node {node_name} of module type {node_module_type}?  Defaulting to strict, disallowing permutations around it."
                      )
                  # is_real coupled with disallowed C and K permutations will poison real parents and real children
                  fx_graph[node_name]["is_real"] = True
                  # dummy entries:
                  fx_graph[node_name]["C_param"] = 1
                  fx_graph[node_name]["K_param"] = 1
                  fx_graph[node_name]["groups_param"] = 1
  
              # MHA nodes only handle the in_proj, need to add out_proj nodes explicitly
              # keep track here so we can iterate directly and change fx_graph keys
              if (
                  node_module_type
                  == "torch.nn.modules.activation.MultiheadAttention"
              ):
                  MHA_nodes.append(node_name)
  
          if cls.__verbosity > 1:
              if node_module_type == "get_attr":
                  print(
                      f"\tInitialized node {node_name} of type {node_module_type}"
                  )
              else:
                  print(
                      f"\tInitialized node {node_name} of type {node_module_type}: {fx_graph[node_name]}"
                  )
  
      for MHA_node in MHA_nodes:
          fx_graph = Permutation.insert_MHA_out_proj(
              fx_graph, MHA_node, cls.__verbosity
          )
  
      return fx_graph
  
imports: import os
  import torch
  import json
  import string
  import time
  import numpy
  import sys
  import builtins
  import io
label_desc: Use image node_id 26 for calling the Permutation obj's underlying member method code with example usage: obj.init_permutation_flags(cls, fx_graph) and returns: fx_graph