code: def define_factor_types(num_vars, len_feat, edge_table):
      """Define factor types
  
      Args:
          num_vars: number of variables in factor graph
          len_feat: length of the feature vector
          edge_table: edge table defines pair-wise node indeces
  
      Returns:
          v_factor_types: list of all unary and pair-wise factor types
      """
      n_stats = 2  # for binary status
      v_factor_types = {}
      n_edges = edge_table.shape[0]
  
      # unary factors
      cards_u = np.array([n_stats], np.int32)
      w_u = np.zeros(n_stats * len_feat)
      for i in range(num_vars):
          v_factor_types[i] = sg.create_factor_type(
              "TableFactorType", type_id=i, cards=cards_u, w=w_u
          )
  
      # pair-wise factors
      cards_pw = np.array([n_stats, n_stats], np.int32)
      w_pw = np.zeros(n_stats * n_stats)
      for j in range(n_edges):
          v_factor_types[j + num_vars] = sg.create_factor_type(
              "TableFactorType",
              type_id=j + num_vars,
              cards=cards_pw,
              w=w_pw,
          )
  
      return v_factor_types
  
file_path: shogun/examples/undocumented/python/structure_graphcuts.py
imports: import numpy
  import itertools
  import shogun
label_desc: Use image node_id 2 for calling a global function with example usage: define_factor_types(num_vars, len_feat, edge_table) and returns: v_factor_types