code: def test_summarize_weighted_flat(X, w, probs):
      w = numpy.array(w)[:, 0]
  
      d = JointCategorical(probs)
      d.summarize(X[:4], sample_weight=w[:4])
      assert_array_almost_equal(d._w_sum, [3.9, 3.9, 3.9])
      assert_array_almost_equal(
          d._xw_sum,
          [
              [[0.0000, 2.8000], [0.0000, 0.0000], [0.0000, 0.0000]],
              [[0.0000, 0.0000], [0.0000, 0.0000], [1.1000, 0.0000]],
          ],
      )
  
      d.summarize(X[4:], sample_weight=w[4:])
      assert_array_almost_equal(d._w_sum, [13.5, 13.5, 13.5])
      assert_array_almost_equal(
          d._xw_sum,
          [
              [[0.0000, 2.8000], [2.3000, 0.0000], [0.0000, 0.0000]],
              [[0.0000, 0.0000], [7.3000, 0.0000], [1.1000, 0.0000]],
          ],
      )
  
      d = JointCategorical(probs)
      d.summarize(X, sample_weight=w)
      assert_array_almost_equal(d._w_sum, [13.5, 13.5, 13.5])
      assert_array_almost_equal(
          d._xw_sum,
          [
              [[0.0000, 2.8000], [2.3000, 0.0000], [0.0000, 0.0000]],
              [[0.0000, 0.0000], [7.3000, 0.0000], [1.1000, 0.0000]],
          ],
      )
  
imports: import numpy
  import torch
  import pytest
  from pomegranate.distributions import JointCategorical
  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 18 for calling a global function with example usage: test_summarize_weighted_flat(X, w, probs) without return types