code: def __idx_node_mapping(node_names: OrderedSet):
      """
      Obtain the node name to index and index to node name mappings.
  
      :param node_names: Name of all nodes in the graph.
      :return: node to index and index to node mappings.
      """
      node2idx = {}
      idx2node = {}
      for i, node in enumerate(node_names.get_all()):
          node2idx[node] = i
          idx2node[i] = node
      return node2idx, idx2node
  
file_path: dowhy/dowhy/causal_identifier/id_identifier.py
imports: from typing import Dict, List, Optional, Set, Union
  import networkx
  import numpy
  from dowhy.graph import get_adjacency_matrix
  from dowhy.utils.api import parse_state
  from dowhy.utils.graph_operations import find_ancestor, find_c_components, induced_graph
  from dowhy.utils.ordered_set import OrderedSet
label_desc: Use image node_id 3 for calling a global function with example usage: __idx_node_mapping(node_names) and returns: node2idx,  idx2node