code: def test_from_summaries_weighted(model, X, w):
      model.summarize(X, sample_weight=w)
      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.6, 0.266667, 0.133333]]
      )
      assert_array_almost_equal(
          model.distributions[1].probs[0],
          [
              [0.222222, 0.555556, 0.222222],
              [0.25, 0.5, 0.25],
              [0.0, 1.0, 0.0],
          ],
      )
      assert_array_almost_equal(
          model.distributions[2].probs[0],
          [
              [
                  [0.0000, 1.0000, 0.0000],
                  [0.7143, 0.2857, 0.0000],
                  [0.0000, 1.0000, 0.0000],
              ],
              [
                  [0.6000, 0.3000, 0.1000],
                  [1.0000, 0.0000, 0.0000],
                  [1.0000, 0.0000, 0.0000],
              ],
              [
                  [1.0000, 0.0000, 0.0000],
                  [1.0000, 0.0000, 0.0000],
                  [0.3333, 0.3333, 0.3333],
              ],
          ],
          4,
      )
  
      assert_array_almost_equal(
          model.distributions[0]._log_probs,
          [[-0.510826, -1.321756, -2.014903]],
      )
      assert_array_almost_equal(
          model.distributions[1]._log_probs[0],
          [
              [-1.504077, -0.587787, -1.504077],
              [-1.386294, -0.693147, -1.386294],
              [-inf, 0.0, -inf],
          ],
      )
      assert_array_almost_equal(
          model.distributions[2]._log_probs[0],
          [
              [
                  [-inf, 0.0000, -inf],
                  [-0.3365, -1.2528, -inf],
                  [-inf, 0.0000, -inf],
              ],
              [
                  [-0.5108, -1.2040, -2.3026],
                  [0.0000, -inf, -inf],
                  [0.0000, -inf, -inf],
              ],
              [
                  [0.0000, -inf, -inf],
                  [0.0000, -inf, -inf],
                  [-1.0986, -1.0986, -1.0986],
              ],
          ],
          4,
      )
  
      X_ = numpy.array(X)
      d = Categorical().fit(X_[:, 0], sample_weight=w)
      d2 = ConditionalCategorical().fit(X_[:, :2], sample_weight=w)
  
      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, sample_weight=w)
      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.6, 0.266667, 0.133333]]
      )
      assert_array_almost_equal(
          model.distributions[1].probs[0],
          [
              [0.222222, 0.555556, 0.222222],
              [0.25, 0.5, 0.25],
              [0.0, 1.0, 0.0],
          ],
      )
      assert_array_almost_equal(
          model.distributions[2].probs[0],
          [
              [
                  [0.0000, 1.0000, 0.0000],
                  [0.7143, 0.2857, 0.0000],
                  [0.0000, 1.0000, 0.0000],
              ],
              [
                  [0.6000, 0.3000, 0.1000],
                  [1.0000, 0.0000, 0.0000],
                  [1.0000, 0.0000, 0.0000],
              ],
              [
                  [1.0000, 0.0000, 0.0000],
                  [1.0000, 0.0000, 0.0000],
                  [0.3333, 0.3333, 0.3333],
              ],
          ],
          4,
      )
  
      assert_array_almost_equal(
          model.distributions[0]._log_probs,
          [[-0.510826, -1.321756, -2.014903]],
      )
      assert_array_almost_equal(
          model.distributions[1]._log_probs[0],
          [
              [-1.504077, -0.587787, -1.504077],
              [-1.386294, -0.693147, -1.386294],
              [-inf, 0.0, -inf],
          ],
      )
      assert_array_almost_equal(
          model.distributions[2]._log_probs[0],
          [
              [
                  [-inf, 0.0000, -inf],
                  [-0.3365, -1.2528, -inf],
                  [-inf, 0.0000, -inf],
              ],
              [
                  [-0.5108, -1.2040, -2.3026],
                  [0.0000, -inf, -inf],
                  [0.0000, -inf, -inf],
              ],
              [
                  [0.0000, -inf, -inf],
                  [0.0000, -inf, -inf],
                  [-1.0986, -1.0986, -1.0986],
              ],
          ],
          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 17 for calling a global function with example usage: test_from_summaries_weighted(model, X, w) without return types