class_docstr: When expanding the columns from variables to features, this class keeps
  track of the 1:m mapping between the collapsed and expanded columns.
  
  Args:
      schema: A dictionary mapping a variable (can be any hashable object) to
          a data type. Permissible data types are stored in the class
          attribute ``PERMISSIBLE_TYPES``.
class_docstr_tok: ["When","expanding","the","columns","from","variables","to","features",",","this","class","keeps","track","of","the","1",":","m","mapping","between","the","collapsed","and","expanded","columns",".","Args",":","schema",":","A","dictionary","mapping","a","variable","(","can","be","any","hashable","object",")","to","a","data","type",".","Permissible","data","types","are","stored","in","the","class","attribute","``","PERMISSIBLE_TYPES","``","."]
code: def __init__(self, schema: Dict[Hashable, str]):
      # 0. get all variables
      self.variable_type_dict = OrderedDict(
          [
              (x, [k for k, v in schema.items() if x in v])
              for x in self.PERMISSIBLE_TYPES
          ]
      )
  
      # 1. split categorical variable into features
      # dictionary: categorical variable to cardinality
      cat_card_dict = OrderedDict(
          [
              (cat_var, int(v.split(":")[1]))
              for cat_var, v in schema.items()
              if self.EXPANDABLE_TYPE in v
          ]
      )
  
      # dictionary: categorical feature to variable (C:1 mapping)
      self._cat_fte_var_dict = OrderedDict(
          [
              (f"{cat_var}_{i}", cat_var)
              for cat_var, card in cat_card_dict.items()
              for i in range(card)
          ]
      )
      cat_feature_list = list(self._cat_fte_var_dict.keys())
  
      # we put them together with the cont + binary in a feature list
      self.feature_list = (
          self.variable_type_dict["binary"]
          + self.variable_type_dict["continuous"]
          + self.variable_type_dict["count"]
          + cat_feature_list
      )
  
      # 2. we assign an index to each feature
      # dictionary: feature to index
      self._fte_index_dict = {
          fte: ix for ix, fte in enumerate(self.feature_list)
      }
  
      # 3. map a feature to all corresponding (expanded) columns
      # dictionary: variable to indices of all corresponding features
      self.var_indices_dict = {
          var: [self._fte_index_dict[var]]
          for var in self.variable_type_dict["continuous"]
          + self.variable_type_dict["binary"]
          + self.variable_type_dict["count"]
      }
      self.var_indices_dict.update(
          {
              k: [
                  self._fte_index_dict[fte]
                  for fte, var in self._cat_fte_var_dict.items()
                  if var == k
              ]
              for k in self.variable_type_dict["categorical"]
          }
      )
  
file_path: causalnex/causalnex/structure/categorical_variable_mapper.py
imports: import re
  from collections import OrderedDict
  from itertools import chain
  from typing import Dict, Hashable, Iterator, List, Optional, Set, Union
  from networkx.classes.reportviews import NodeView
label_desc: Use image node_id 1 to create a new VariableFeatureMapper object  with example: obj = VariableFeatureMapper(schema)