code: def test_label_propagation_closed_form(setup):
      n_classes = 2
      X, y = make_classification(
          n_classes=n_classes, n_samples=200, random_state=0
      )
      y[::3] = -1
      Y = np.zeros((len(y), n_classes + 1))
      Y[np.arange(len(y)), y] = 1
      unlabelled_idx = Y[:, (-1,)].nonzero()[0]
      labelled_idx = (Y[:, (-1,)] == 0).nonzero()[0]
  
      clf = LabelPropagation(max_iter=10000, gamma=0.1)
      clf.fit(X, y)
      # adopting notation from Zhu et al 2002
      T_bar = clf._build_graph().to_numpy()
      Tuu = T_bar[
          tuple(
              np.meshgrid(unlabelled_idx, unlabelled_idx, indexing="ij")
          )
      ]
      Tul = T_bar[
          tuple(
              np.meshgrid(unlabelled_idx, labelled_idx, indexing="ij")
          )
      ]
      Y = Y[:, :-1]
      Y_l = Y[labelled_idx, :]
      Y_u = np.dot(
          np.dot(np.linalg.inv(np.eye(Tuu.shape[0]) - Tuu), Tul), Y_l
      )
  
      expected = Y.copy()
      expected[unlabelled_idx, :] = Y_u
      expected /= expected.sum(axis=1)[:, np.newaxis]
  
      np.testing.assert_array_almost_equal(
          expected, clf.label_distributions_.fetch(), 4
      )
  
file_path: mars/mars/learn/semi_supervised/tests/test_label_propagation.py
imports: import numpy
  import pytest
  from sklearn.datasets import make_classification
  from sklearn.model_selection import train_test_split
  from sklearn.exceptions import ConvergenceWarning
  from sklearn.utils._testing import assert_no_warnings
  from ....None import tensor
  from ...metrics.pairwise import rbf_kernel
  from ...neighbors import NearestNeighbors
  from ..None import LabelPropagation
label_desc: Use image node_id 5 for calling a global function with example usage: test_label_propagation_closed_form(setup) without return types