code: def test_label_propagation(self):
      if "label_propagation" in get_unity().list_toolkit_functions():
          g = self.graph.copy()
          num_vertices = len(g.vertices)
          num_classes = 2
  
          def get_label(vid):
              if vid < 100:
                  return 0
              elif vid > num_vertices - 100:
                  return 1
              else:
                  return None
  
          g.vertices["label"] = g.vertices["__id"].apply(get_label, int)
          m = tc.label_propagation.create(g, label_field="label")
  
          m.summary()
          self.__test_model_save_load_helper__(m)
  
          for row in m.graph.vertices:
              predicted_label = row["predicted_label"]
              if predicted_label is None:
                  for k in ["P%d" % i for i in range(num_classes)]:
                      self.assertAlmostEqual(row[k], 1.0 / num_classes)
              else:
                  sum_of_prob = 0.0
                  for k in ["P%d" % i for i in range(num_classes)]:
                      sum_of_prob += row[k]
                      self.assertGreaterEqual(
                          row["P%d" % predicted_label], row[k]
                      )
                  self.assertAlmostEqual(sum_of_prob, 1.0)
  
          # Add more options: weighted edges, change self weight, and undirected edges
          def get_edge_weight(vid):
              return float(vid) * 10 / num_vertices
  
          g.edges["weight"] = g.edges["__src_id"].apply(
              get_edge_weight, float
          )
          m = tc.label_propagation.create(
              g,
              label_field="label",
              threshold=1e-2,
              weight_field="weight",
              self_weight=0.5,
              undirected=True,
          )
  
          # Test early termination using max_iteration
          max_iter = 3
          m = tc.label_propagation.create(
              g,
              label_field="label",
              threshold=1e-10,
              max_iterations=max_iter,
          )
          self.assertEqual(m.num_iterations, max_iter)
  
          # Test that the predict class should be None if all class probabilities are equal
          g = g.add_vertices(tc.SFrame({"__id": [-1]}))
          m = tc.label_propagation.create(
              g,
              label_field="label",
              threshold=1e-10,
              max_iterations=max_iter,
          )
          result = m.graph.vertices
          self.assertEqual(
              result[result["__id"] == -1]["predicted_label"][0], None
          )
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  from .None import util
  import unittest
  import pandas
  from pandas.util.testing import assert_frame_equal
  import turicreate
  from turicreate._connect.main import get_unity
  from turicreate.toolkits._main import ToolkitError
  from turicreate.data_structures.sgraph import SGraph
  from turicreate.data_structures.sframe import SFrame
  import sys
label_desc: Use image node_id 4 for calling the GraphAnalyticsTest obj's underlying member method code with example usage: obj.test_label_propagation() and returns: unknown, int, int, None