code: def test_serialization(X, model):
      torch.save(model, ".pytest.torch")
      model2 = torch.load(".pytest.torch")
      os.system("rm .pytest.torch")
  
      assert model is not model2
  
      assert_array_almost_equal(model2.centroids, model.centroids)
      assert_array_almost_equal(model2._w_sum, model._w_sum)
      assert_array_almost_equal(model2._xw_sum, model._xw_sum)
      assert_array_almost_equal(
          model2._centroid_sum, model._centroid_sum
      )
  
      assert_array_almost_equal(
          model2._distances(X), model._distances(X)
      )
  
imports: import os
  import numpy
  import torch
  import pytest
  from pomegranate.kmeans import KMeans
  from .distributions._utils import _test_initialization_raises_one_parameter
  from .distributions._utils import _test_initialization
  from .distributions._utils import _test_predictions
  from .distributions._utils import _test_efd_from_summaries
  from .distributions._utils import _test_raises
  from nose.tools import assert_raises
  from numpy.testing import assert_array_almost_equal
label_desc: Use image node_id 29 for calling a global function with example usage: test_serialization(X, model) without return types