code: def test_fit(X, w, probs):
      d = ConditionalCategorical(probs)
      d.fit(X)
      for i in range(d.d):
          assert_raises(
              AssertionError,
              assert_array_almost_equal,
              probs[i],
              d.probs[i],
          )
  
      for param in probs, None:
          d = ConditionalCategorical(param)
          d.fit(X[:4])
          _test_efd_from_summaries(
              d,
              "probs",
              "_log_probs",
              [
                  [[0.50, 0.50], [0.75, 0.25]],
                  [[0.50, 0.50], [0.50, 0.50], [0.50, 0.50]],
                  [[1.00, 0.00], [0.00, 1.00]],
              ],
          )
  
          d.fit(X[4:])
          _test_efd_from_summaries(
              d,
              "probs",
              "_log_probs",
              [
                  [[1.00, 0.00], [0.50, 0.50]],
                  [[0.50, 0.50], [0.6666667, 0.33333334], [0.50, 0.50]],
                  [[1.00, 0.00], [0.00, 1.00]],
              ],
          )
  
          d = ConditionalCategorical(param)
          d.fit(X)
          _test_efd_from_summaries(
              d,
              "probs",
              "_log_probs",
              [
                  [[1.0, 0.0], [0.6666667, 0.33333334]],
                  [[0.50, 0.50], [0.6666667, 0.33333334], [0.50, 0.50]],
                  [[1.00, 0.00], [0.00, 1.00]],
              ],
          )
  
imports: import numpy
  import torch
  import pytest
  from pomegranate.distributions import ConditionalCategorical
  from ._utils import _test_initialization_raises_one_parameter
  from ._utils import _test_initialization
  from ._utils import _test_predictions
  from ._utils import _test_raises
  from nose.tools import assert_raises
  from numpy.testing import assert_array_almost_equal
label_desc: Use image node_id 31 for calling a global function with example usage: test_fit(X, w, probs) without return types