docstr: test whether the relation is accurate, implicitely tests sequence of
  nodes.
docstr_tok: ["test","whether","the","relation","is","accurate",",","implicitely","tests","sequence","of","nodes","."]
code: def test_independence(
      self, graph_gen, seed, num_nodes, n_categories, distribution
  ):
      """
      test whether the relation is accurate, implicitely tests sequence of
      nodes.
      """
      sm = graph_gen(num_nodes=num_nodes, seed=seed, weight=None)
      nodes = sm.nodes()
  
      df = generate_categorical_dataframe(
          sm,
          n_samples=100000,
          distribution=distribution,
          n_categories=n_categories,
          seed=seed,
          noise_scale=1,
          intercept=False,
      )
  
      tol = 0.05
  
      # independent links
      for node in nodes:
          if node == "aa":
              continue
          joint_proba, factored_proba = calculate_proba(
              df, "aa_0", node + "_0"
          )
          if node == "ab":
              assert not np.isclose(
                  joint_proba, factored_proba, rtol=tol, atol=0
              )
          else:
              assert np.isclose(
                  joint_proba, factored_proba, rtol=tol, atol=0
              )
  
imports: import re
  import string
  from itertools import product
  import numpy
  import pandas
  import pytest
  from scipy import stats
  from sklearn.gaussian_process.kernels import RBF
  from causalnex.structure import StructureModel
  from causalnex.structure.data_generators import gen_stationary_dyn_net_and_df, generate_binary_data, generate_binary_dataframe, generate_categorical_dataframe, generate_continuous_data, generate_continuous_dataframe, generate_count_dataframe, generate_dataframe_dynamic, generate_structure, generate_structure_dynamic
  from tests.structure.data_generators.test_core import calculate_proba
label_desc: Use image node_id 9 for calling the TestGenerateCategoricalData obj's underlying member method code with example usage: obj.test_independence(graph_gen, seed, num_nodes, n_categories, distribution) without return types