code: def test_serialization(X):
      d = Gamma().fit(X[:4])
      d.summarize(X[4:])
  
      rates = [1.704751, 1.222564, 2.227916]
  
      assert_array_almost_equal(d.rates, rates)
      assert_array_almost_equal(d._log_rates, numpy.log(rates))
  
      torch.save(d, ".pytest.torch")
      d2 = torch.load(".pytest.torch")
      os.system("rm .pytest.torch")
  
      assert_array_almost_equal(d2.rates, rates)
      assert_array_almost_equal(d2._log_rates, numpy.log(rates))
  
      assert_array_almost_equal(d2._w_sum, [3.0, 3.0, 3.0])
      assert_array_almost_equal(d2._xw_sum, [11.0, 4.2, 4.4])
      assert_array_almost_equal(
          d.log_probability(X), d2.log_probability(X)
      )
  
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 40 for calling a global function with example usage: test_serialization(X) without return types