code: def test_masked_rand_index():
      numpy.random.seed(310)
      i, j = numpy.mgrid[0:10, 0:20]
      #
      # Create a labeling with two objects 0:10, 0:5 and 0:10, 15:20.
      # The background class is 0:10, 5:15
      #
      ground_truth = (j < 5) | (j >= 15)
      #
      # Add a 3x4 square in the middle
      #
      test = ground_truth.copy()
      test[4:7, 8:12] = True
      #
      # Remove both one correct and one incorect pixel
      #
      mask = numpy.ones(ground_truth.shape, bool)
      mask[4, 4] = False
      mask[5, 9] = False
      #
      # See notes from 03_10
      #
      expected_rand_index = 0.9503666
      expected_adj_rand_index = 0.8907784
      workspace, module = make_workspace(
          dict(image=ground_truth, mask=mask),
          dict(image=test, mask=mask),
      )
      module.run(workspace)
      measurements = workspace.measurements
  
      mname = "_".join(
          (
              cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP,
              cellprofiler.modules.measureimageoverlap.FTR_RAND_INDEX,
              TEST_IMAGE_NAME,
          )
      )
      assert (
          round(
              abs(
                  measurements.get_current_image_measurement(mname)
                  - expected_rand_index
              ),
              6,
          )
          == 0
      )
      mname = "_".join(
          (
              cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP,
              cellprofiler.modules.measureimageoverlap.FTR_ADJUSTED_RAND_INDEX,
              TEST_IMAGE_NAME,
          )
      )
      assert (
          round(
              abs(
                  measurements.get_current_image_measurement(mname)
                  - expected_adj_rand_index
              ),
              6,
          )
          == 0
      )
  
imports: import io
  import numpy
  import numpy.random
  import numpy.testing
  import scipy.ndimage
  import cellprofiler_library.opts.measureimageoverlap
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler_core.module
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.preferences
  import cellprofiler_core.workspace
  from cellprofiler_core.constants.measurement import COLTYPE_FLOAT
  import cellprofiler.modules.measureimageoverlap
  import tests.frontend.modules
label_desc: Use image node_id 16 for calling a global function with example usage: test_masked_rand_index() without return types