code: def test_from_summaries(model, X):
      model.summarize(X)
      model.from_summaries()
  
      assert_array_almost_equal(
          model.distributions[0]._xw_sum, [[0.0, 0.0, 0]]
      )
      assert_array_almost_equal(
          model.distributions[1]._xw_sum[0],
          [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]],
      )
      assert_array_almost_equal(
          model.distributions[2]._xw_sum[0],
          [
              [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]],
              [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]],
              [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]],
          ],
      )
  
      assert_array_almost_equal(
          model.distributions[0].probs, [[0.363636, 0.454545, 0.181818]]
      )
      assert_array_almost_equal(
          model.distributions[1].probs[0],
          [[0.5, 0.25, 0.25], [0.2, 0.6, 0.2], [0.0, 0.5, 0.5]],
      )
      assert_array_almost_equal(
          model.distributions[2].probs[0],
          [
              [
                  [0.6667, 0.3333, 0.0000],
                  [0.5000, 0.5000, 0.0000],
                  [0.0000, 1.0000, 0.0000],
              ],
              [
                  [0.4000, 0.4000, 0.2000],
                  [0.6667, 0.0000, 0.3333],
                  [1.0000, 0.0000, 0.0000],
              ],
              [
                  [1.0000, 0.0000, 0.0000],
                  [1.0000, 0.0000, 0.0000],
                  [0.0000, 0.5000, 0.5000],
              ],
          ],
          4,
      )
  
      assert_array_almost_equal(
          model.distributions[0]._log_probs,
          [[-1.011601, -0.788457, -1.704748]],
      )
      assert_array_almost_equal(
          model.distributions[1]._log_probs[0],
          [
              [-0.693147, -1.386294, -1.386294],
              [-1.609438, -0.510826, -1.609438],
              [-inf, -0.693147, -0.693147],
          ],
      )
      assert_array_almost_equal(
          model.distributions[2]._log_probs[0],
          [
              [
                  [-0.4055, -1.0986, -inf],
                  [-0.6931, -0.6931, -inf],
                  [-inf, 0.0000, -inf],
              ],
              [
                  [-0.9163, -0.9163, -1.6094],
                  [-0.4055, -inf, -1.0986],
                  [0.0000, -inf, -inf],
              ],
              [
                  [0.0000, -inf, -inf],
                  [0.0000, -inf, -inf],
                  [-inf, -0.6931, -0.6931],
              ],
          ],
          4,
      )
  
      X_ = numpy.array(X)
      d = Categorical().fit(X_[:, 0])
      d2 = ConditionalCategorical().fit(X_[:, :2])
  
      assert_array_almost_equal(d.probs, model.distributions[0].probs)
      assert_array_almost_equal(
          d2.probs[0], model.distributions[1].probs[0]
      )
  
      model = MarkovChain(
          [
              Categorical(),
              ConditionalCategorical(),
              ConditionalCategorical(),
          ]
      )
      model.summarize(X)
      model.from_summaries()
  
      assert_array_almost_equal(
          model.distributions[0]._xw_sum, [[0.0, 0.0, 0]]
      )
      assert_array_almost_equal(
          model.distributions[1]._xw_sum[0],
          [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]],
      )
      assert_array_almost_equal(
          model.distributions[2]._xw_sum[0],
          [
              [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]],
              [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]],
              [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]],
          ],
      )
  
      assert_array_almost_equal(
          model.distributions[0].probs, [[0.363636, 0.454545, 0.181818]]
      )
      assert_array_almost_equal(
          model.distributions[1].probs[0],
          [[0.5, 0.25, 0.25], [0.2, 0.6, 0.2], [0.0, 0.5, 0.5]],
      )
      assert_array_almost_equal(
          model.distributions[2].probs[0],
          [
              [
                  [0.6667, 0.3333, 0.0000],
                  [0.5000, 0.5000, 0.0000],
                  [0.0000, 1.0000, 0.0000],
              ],
              [
                  [0.4000, 0.4000, 0.2000],
                  [0.6667, 0.0000, 0.3333],
                  [1.0000, 0.0000, 0.0000],
              ],
              [
                  [1.0000, 0.0000, 0.0000],
                  [1.0000, 0.0000, 0.0000],
                  [0.0000, 0.5000, 0.5000],
              ],
          ],
          4,
      )
  
      assert_array_almost_equal(
          model.distributions[0]._log_probs,
          [[-1.011601, -0.788457, -1.704748]],
      )
      assert_array_almost_equal(
          model.distributions[1]._log_probs[0],
          [
              [-0.693147, -1.386294, -1.386294],
              [-1.609438, -0.510826, -1.609438],
              [-inf, -0.693147, -0.693147],
          ],
      )
      assert_array_almost_equal(
          model.distributions[2]._log_probs[0],
          [
              [
                  [-0.4055, -1.0986, -inf],
                  [-0.6931, -0.6931, -inf],
                  [-inf, 0.0000, -inf],
              ],
              [
                  [-0.9163, -0.9163, -1.6094],
                  [-0.4055, -inf, -1.0986],
                  [0.0000, -inf, -inf],
              ],
              [
                  [0.0000, -inf, -inf],
                  [0.0000, -inf, -inf],
                  [-inf, -0.6931, -0.6931],
              ],
          ],
          4,
      )
  
imports: import numpy
  import torch
  import pytest
  from pomegranate.markov_chain import MarkovChain
  from pomegranate.distributions import Categorical
  from pomegranate.distributions import ConditionalCategorical
  from .distributions._utils import _test_initialization_raises_one_parameter
  from .distributions._utils import _test_initialization
  from .distributions._utils import _test_predictions
  from .distributions._utils import _test_efd_from_summaries
  from .distributions._utils import _test_raises
  from nose.tools import assert_raises
  from numpy.testing import assert_array_almost_equal
label_desc: Use image node_id 16 for calling a global function with example usage: test_from_summaries(model, X) without return types