code: def test_summarize_weighted(X, X2, w, w2, shapes, rates):
      d = Gamma(shapes, rates)
      d.summarize(X[:4], sample_weight=w[:4])
      assert_array_almost_equal(d._w_sum, [3.0, 3.0, 3.0])
      assert_array_almost_equal(d._xw_sum, [2.1, 2.5, 3.1])
      assert_array_almost_equal(
          d._logx_w_sum, [-1.290984, -2.476939, -0.168419]
      )
  
      d.summarize(X[4:], sample_weight=w[4:])
      assert_array_almost_equal(d._w_sum, [11.0, 11.0, 11.0])
      assert_array_almost_equal(d._xw_sum, [28.9, 12.0, 8.799999])
      assert_array_almost_equal(
          d._logx_w_sum, [8.091207, -1.310356, -9.407159]
      )
  
      d = Gamma(shapes, rates)
      d.summarize(X, sample_weight=w)
      assert_array_almost_equal(d._w_sum, [11.0, 11.0, 11.0])
      assert_array_almost_equal(d._xw_sum, [28.9, 12.0, 8.799999])
      assert_array_almost_equal(
          d._logx_w_sum, [8.091207, -1.310356, -9.407158]
      )
  
      d = Gamma()
      d.summarize(X2, sample_weight=w2)
      assert_array_almost_equal(d._w_sum, [4.6, 4.6, 4.6, 4.6])
      assert_array_almost_equal(d._xw_sum, [23.02, 4.4, 9.61, 5.94])
      assert_array_almost_equal(
          d._logx_w_sum, [6.586476, -0.428876, 3.168982, 1.039625]
      )
  
      d = Gamma([0, 0, 0, 0], [0, 0, 0, 0])
      d.summarize(X2, sample_weight=w2)
      assert_array_almost_equal(d._w_sum, [4.6, 4.6, 4.6, 4.6])
      assert_array_almost_equal(d._xw_sum, [23.02, 4.4, 9.61, 5.94])
      assert_array_almost_equal(
          d._logx_w_sum, [6.586476, -0.428876, 3.168982, 1.039625]
      )
  
imports: import os
  import numpy
  import torch
  import pytest
  from pomegranate.distributions import Gamma
  from ._utils import _test_initialization_raises_two_parameters
  from ._utils import _test_initialization
  from ._utils import _test_predictions
  from ._utils import _test_efd_from_summaries
  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 22 for calling a global function with example usage: test_summarize_weighted(X, X2, w, w2, shapes, rates) without return types