code: def test_categorical_from_structure(X):
      structure = ((), (0,), (1, 3), ())
      distributions = _from_structure(X, structure=structure)
      model = BayesianNetwork(distributions, structure=structure)
  
      assert isinstance(model.distributions[0], Categorical)
      assert isinstance(model.distributions[1], ConditionalCategorical)
      assert isinstance(model.distributions[2], ConditionalCategorical)
      assert isinstance(model.distributions[3], Categorical)
  
      p0 = model.distributions[0].probs
      p1 = model.distributions[1].probs[0]
      p2 = model.distributions[2].probs[0]
      p3 = model.distributions[3].probs
  
      assert_array_almost_equal(p0, [[0.454545, 0.545455]])
      assert_array_almost_equal(
          p1, [[0.4, 0.4, 0.2], [0.166667, 0.5, 0.333333]]
      )
      assert_array_almost_equal(
          p2,
          [
              [[0.0000, 1.0000], [0.5000, 0.5000]],
              [[0.5000, 0.5000], [1.0000, 0.0000]],
              [[0.5000, 0.5000], [0.0000, 1.0000]],
          ],
      )
      assert_array_almost_equal(p3, [[0.4545, 0.5455]], 4)
  
imports: import numpy
  import torch
  import pytest
  from pomegranate.bayesian_network import BayesianNetwork
  from pomegranate.bayesian_network import _from_structure
  from pomegranate.bayesian_network import _learn_structure
  from pomegranate.bayesian_network import _categorical_exact
  from pomegranate.bayesian_network import _categorical_chow_liu
  from pomegranate.distributions import Categorical
  from pomegranate.distributions import ConditionalCategorical
  from nose.tools import assert_raises
  from numpy.testing import assert_array_almost_equal
label_desc: Use image node_id 17 for calling a global function with example usage: test_categorical_from_structure(X) without return types