code: def gen_data(ftype, num_samples, show_data=False):
      np.random.seed(1)
  
      samples = sg.FactorGraphFeatures(num_samples)
      labels = sg.FactorGraphLabels(num_samples)
  
      for i in range(num_samples):
          vc = np.array([2, 2, 2], np.int32)
          fg = sg.FactorGraph(vc)
  
          data1 = np.array(
              [2.0 * np.random.random_sample() - 1.0 for i in range(2)]
          )
          vind1 = np.array([0, 1], np.int32)
          fac1 = sg.Factor(ftype[0], vind1, data1)
          fg.add_factor(fac1)
  
          data2 = np.array(
              [2.0 * np.random.random_sample() - 1.0 for i in range(2)]
          )
          vind2 = np.array([1, 2], np.int32)
          fac2 = sg.Factor(ftype[0], vind2, data2)
          fg.add_factor(fac2)
  
          data3 = np.array(
              [2.0 * np.random.random_sample() - 1.0 for i in range(2)]
          )
          vind3 = np.array([0], np.int32)
          fac3 = sg.Factor(ftype[1], vind3, data3)
          fg.add_factor(fac3)
  
          data4 = np.array(
              [2.0 * np.random.random_sample() - 1.0 for i in range(2)]
          )
          vind4 = np.array([1], np.int32)
          fac4 = sg.Factor(ftype[1], vind4, data4)
          fg.add_factor(fac4)
  
          data5 = np.array(
              [2.0 * np.random.random_sample() - 1.0 for i in range(2)]
          )
          vind5 = np.array([2], np.int32)
          fac5 = sg.Factor(ftype[1], vind5, data5)
          fg.add_factor(fac5)
  
          data6 = np.array([1.0])
          vind6 = np.array([0], np.int32)
          fac6 = sg.Factor(ftype[2], vind6, data6)
          fg.add_factor(fac6)
  
          data7 = np.array([1.0])
          vind7 = np.array([2], np.int32)
          fac7 = sg.Factor(ftype[2], vind7, data7)
          fg.add_factor(fac7)
  
          samples.add_sample(fg)
          fg.connect_components()
          fg.compute_energies()
  
          infer_met = sg.MAPInference(fg, sg.TREE_MAX_PROD)
          infer_met.inference()
  
          fg_obs = infer_met.get_structured_outputs()
          labels.add_label(fg_obs)
  
          if show_data:
              state = fg_obs.get_data()
              print(state)
  
      return samples, labels
  
label_desc: Use image node_id 1 for calling a global function with example usage: gen_data(ftype, num_samples, show_data) and returns: samples,  labels