code: def test_fit_weighted(X, w, shapes, rates):
      for param in shapes, None:
          d = Gamma(shapes, rates)
          d.fit(X[:4], sample_weight=w[:4])
          _test_fit_params(
              d,
              [6.951008, 0.907765, 5.783966],
              [9.930012, 1.089317, 5.597386],
              [9.468783, 0.017088, 5.538523],
          )
  
          d.fit(X[4:], sample_weight=w[4:])
          _test_fit_params(
              d,
              [13.98193, 19.375662, 0.73567],
              [4.17371, 16.316347, 1.032519],
              [-2.527685, 16.604717, -0.195563],
          )
  
          d = Gamma(shapes, rates)
          d.fit(X, sample_weight=w)
          _test_fit_params(
              d,
              [2.323329, 2.580077, 0.922164],
              [0.884312, 2.365071, 1.152706],
              [-0.453977, 1.878409, 0.08094],
          )
  
      X = [[1.2, 0.5, 1.1, 1.9], [6.2, 1.1, 2.4, 1.1]]
  
      w = [[1.1], [3.5]]
  
      d = Gamma()
      d.fit(X, sample_weight=w)
      _test_fit_params(
          d,
          [2.957831, 10.413525, 10.615726, 17.029907],
          [0.591052, 10.886867, 5.081409, 13.188144],
          [-2.209965, 11.121039, 3.048994, 13.169821],
      )
  
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 37 for calling a global function with example usage: test_fit_weighted(X, w, shapes, rates) without return types