code: def g_sq(X, Y, Z, data, boolean=True, **kwargs):
      """
      G squared test for conditional independence. Also commonly known as G-test,
      likelihood-ratio or maximum likelihood statistical significance test.
      Tests the null hypothesis that X is independent of Y given Zs.
  
      Parameters
      ----------
      X: int, string, hashable object
          A variable name contained in the data set
  
      Y: int, string, hashable object
          A variable name contained in the data set, different from X
  
      Z: list (array-like)
          A list of variable names contained in the data set, different from X and Y.
          This is the separating set that (potentially) makes X and Y independent.
          Default: []
  
      data: pandas.DataFrame
          The dataset on which to test the independence condition.
  
      boolean: bool
          If boolean=True, an additional argument `significance_level` must be
          specified. If p_value of the test is greater than equal to
          `significance_level`, returns True. Otherwise returns False. If
          boolean=False, returns the chi2 and p_value of the test.
  
      Returns
      -------
      CI Test Results: tuple or bool
          If boolean = False, Returns a tuple (chi, p_value, dof). `chi` is the
          chi-squared test statistic. The `p_value` for the test, i.e. the
          probability of observing the computed chi-square statistic (or an even
          higher value), given the null hypothesis that X \u27C2 Y | Zs is True.
          If boolean = True, returns True if the p_value of the test is greater
          than `significance_level` else returns False.
  
      References
      ----------
      [1] https://en.wikipedia.org/wiki/G-test
  
      Examples
      --------
      >>> import pandas as pd
      >>> import numpy as np
      >>> data = pd.DataFrame(np.random.randint(0, 2, size=(50000, 4)), columns=list('ABCD'))
      >>> data['E'] = data['A'] + data['B'] + data['C']
      >>> g_sq(X='A', Y='C', Z=[], data=data, boolean=True, significance_level=0.05)
      True
      >>> g_sq(X='A', Y='B', Z=['D'], data=data, boolean=True, significance_level=0.05)
      True
      >>> g_sq(X='A', Y='B', Z=['D', 'E'], data=data, boolean=True, significance_level=0.05)
      False
      """
      return power_divergence(
          X=X,
          Y=Y,
          Z=Z,
          data=data,
          boolean=boolean,
          lambda_="log-likelihood",
          **kwargs,
      )
  
file_path: pgmpy/pgmpy/estimators/CITests.py
imports: import numpy
  import pandas
  from scipy import stats
  from pgmpy.independencies import IndependenceAssertion
  from pgmpy.global_vars import logger
label_desc: Use image node_id 3 for calling a global function with example usage: g_sq(X, Y, Z, data, boolean) and returns: power_divergence