code: def test_chinese_whispers_with_distance():
      assert len(chinese_whispers([(0, 0, 1)])) == 1
      assert (
          len(chinese_whispers([(0, 0, 1), (0, 1, 0.5), (1, 1, 1)]))
          == 2
      )
  
      # Test that values from edges and distances are actually used and that correct values are returned
      labels = chinese_whispers([(0, 0, 1), (0, 1, 1), (1, 1, 1)])
      assert len(labels) == 2
      assert labels[0] == labels[1]
      labels = chinese_whispers([(0, 0, 1), (0, 1, 0.0), (1, 1, 1)])
      assert len(labels) == 2
      assert labels[0] != labels[1]
  
      # Non-trivial test
      edges = []
      r = Random(0)
      for i in range(100):
          edges.append((i, i, 1))
          edges.append((i, r.randint(0, 99), r.random()))
      assert len(chinese_whispers(edges)) == 100
  
imports: from random import Random
  from dlib import chinese_whispers
  from pytest import raises
label_desc: Use image node_id 2 for calling a global function with example usage: test_chinese_whispers_with_distance() without return types