code: def test_filter_by_3_class_rule():
      rules_file_contents = (
          "IF (MyObjects_MyMeasurement > 2.0, [1.0,-1.0,-1.0], [-0.5,0.5,0.5])\n"
          "IF (MyObjects_MyMeasurement > 1.6, [0.5,0.5,-0.5], [-1.0,-1.0,1.0])\n"
      )
      expected_class = [None, "3", "1", "2"]
      rules_path = tempfile.mktemp()
      with open(rules_path, "wt") as fd:
          fd.write(rules_file_contents)
      try:
          for rules_class in ("1", "2", "3"):
              labels = numpy.zeros((10, 20), int)
              labels[3:5, 4:9] = 1
              labels[7:9, 6:12] = 2
              labels[4:9, 14:18] = 3
              workspace, module = make_workspace({"MyObjects": labels})
              assert isinstance(
                  module,
                  cellprofiler.modules.filterobjects.FilterByObjectMeasurement,
              )
              m = workspace.measurements
              m.add_measurement(
                  "MyObjects",
                  "MyMeasurement",
                  numpy.array([1.5, 2.3, 1.8]),
              )
              rules_dir, rules_file = os.path.split(rules_path)
              module.x_name.value = "MyObjects"
              module.mode.value = (
                  cellprofiler.modules.filterobjects.MODE_RULES
              )
              module.rules_file_name.value = rules_file
              module.rules_directory.dir_choice = (
                  cellprofiler_core.preferences.ABSOLUTE_FOLDER_NAME
              )
              module.rules_directory.custom_path = rules_dir
              module.rules_class.value = rules_class
              module.y_name.value = "MyTargetObjects"
              module.run(workspace)
              target_objects = workspace.object_set.get_objects(
                  "MyTargetObjects"
              )
              target_labels = target_objects.segmented
              kept = expected_class.index(rules_class)
              assert numpy.all(target_labels[labels == kept] > 0)
              assert numpy.all(target_labels[labels != kept] == 0)
      finally:
          os.remove(rules_path)
  
imports: import contextlib
  import io
  import os
  import pickle
  import tempfile
  import numpy
  import pytest
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler_core.modules
  from cellprofiler_core.constants.measurement import FF_PARENT, FF_COUNT, FF_CHILDREN_COUNT, M_LOCATION_CENTER_X, M_LOCATION_CENTER_Y, M_LOCATION_CENTER_Z, M_NUMBER_OBJECT_NUMBER
  import cellprofiler.modules.filterobjects
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.preferences
  import cellprofiler_core.workspace
  import tests.frontend.modules
label_desc: Use image node_id 23 for calling a global function with example usage: test_filter_by_3_class_rule() without return types