code: def test_fit_weighted(X, w, model, model2):
      model.fit(X, sample_weight=w)
  
      assert_array_almost_equal(
          model.factors[0].probs, [[0.6548, 0.3452]], 4
      )
      assert_array_almost_equal(
          model.factors[1].probs,
          [
              [[0.1964, 0.3631, 0.0000], [0.0774, 0.0000, 0.0179]],
              [[0.0000, 0.2738, 0.0000], [0.0000, 0.0000, 0.0714]],
          ],
          4,
      )
      assert_array_almost_equal(
          model.factors[2].probs, [[0.8333, 0.1667]], 4
      )
      assert_array_almost_equal(
          model.factors[3].probs,
          [[0.0000, 0.8333], [0.0952, 0.0714]],
          4,
      )
  
      assert_array_almost_equal(model.marginals[0].probs, [[0.5, 0.5]])
      assert_array_almost_equal(
          model.marginals[1].probs, [[1.0 / 3, 1.0 / 3, 1.0 / 3]]
      )
      assert_array_almost_equal(model.marginals[2].probs, [[0.5, 0.5]])
      assert_array_almost_equal(model.marginals[3].probs, [[0.5, 0.5]])
  
      model2.fit(X, sample_weight=w)
      assert_array_almost_equal(
          model2.factors[0].probs, [[0.6548, 0.3452]], 4
      )
      assert_array_almost_equal(
          model2.factors[1].probs,
          [
              [[0.0000, 0.0000, 0.0000], [0.1964, 0.6369, 0.0000]],
              [[0.0774, 0.0000, 0.0179], [0.0000, 0.0000, 0.0714]],
          ],
          4,
      )
      assert_array_almost_equal(
          model2.factors[2].probs,
          [[0.5595, 0.0952], [0.2738, 0.0714]],
          4,
      )
      assert_array_almost_equal(
          model2.factors[3].probs,
          [[0.0952, 0.5595], [0.0000, 0.3452]],
          4,
      )
  
      assert_array_almost_equal(model2.marginals[0].probs, [[0.5, 0.5]])
      assert_array_almost_equal(
          model2.marginals[1].probs, [[1.0 / 3, 1.0 / 3, 1.0 / 3]]
      )
      assert_array_almost_equal(model2.marginals[2].probs, [[0.5, 0.5]])
      assert_array_almost_equal(model2.marginals[3].probs, [[0.5, 0.5]])
  
imports: import numpy
  import torch
  import pytest
  from pomegranate.factor_graph import FactorGraph
  from pomegranate.distributions import Exponential
  from pomegranate.distributions import Categorical
  from pomegranate.distributions import JointCategorical
  from nose.tools import assert_raises
  from numpy.testing import assert_array_almost_equal
label_desc: Use image node_id 24 for calling a global function with example usage: test_fit_weighted(X, w, model, model2) without return types