code: def test_two():
      numpy.random.seed(0)
      labels = numpy.zeros((10, 20), int)
      index = 1
      for i_min, i_max in ((1, 4), (6, 9)):
          for j_min, j_max in ((2, 6), (8, 11), (13, 18)):
              labels[i_min:i_max, j_min:j_max] = index
              index += 1
      num_labels = index - 1
      exps = numpy.exp(numpy.arange(numpy.max(labels)))
      m1 = numpy.random.permutation(exps)
      m2 = numpy.random.permutation(exps)
      for wants_custom_names in (False, True):
          for tm1 in (
              cellprofiler.modules.classifyobjects.TM_MEAN,
              cellprofiler.modules.classifyobjects.TM_MEDIAN,
              cellprofiler.modules.classifyobjects.TM_CUSTOM,
          ):
              for tm2 in (
                  cellprofiler.modules.classifyobjects.TM_MEAN,
                  cellprofiler.modules.classifyobjects.TM_MEDIAN,
                  cellprofiler.modules.classifyobjects.TM_CUSTOM,
              ):
                  workspace, module = make_workspace(
                      labels,
                      cellprofiler.modules.classifyobjects.BY_TWO_MEASUREMENTS,
                      m1,
                      m2,
                  )
                  assert isinstance(
                      module,
                      cellprofiler.modules.classifyobjects.ClassifyObjects,
                  )
                  module.first_threshold_method.value = tm1
                  module.first_threshold.value = 8
                  module.second_threshold_method.value = tm2
                  module.second_threshold.value = 70
                  module.wants_image.value = True
  
                  def cutoff(method, custom_cutoff):
                      if (
                          method
                          == cellprofiler.modules.classifyobjects.TM_MEAN
                      ):
                          return numpy.mean(exps)
                      elif (
                          method
                          == cellprofiler.modules.classifyobjects.TM_MEDIAN
                      ):
                          return numpy.median(exps)
                      else:
                          return custom_cutoff
  
                  c1 = cutoff(tm1, module.first_threshold.value)
                  c2 = cutoff(tm2, module.second_threshold.value)
                  m1_over = m1 >= c1
                  m2_over = m2 >= c2
                  if wants_custom_names:
                      f_names = ("TL", "TR", "BL", "BR")
                      module.wants_custom_names.value = True
                      module.low_low_custom_name.value = f_names[0]
                      module.low_high_custom_name.value = f_names[1]
                      module.high_low_custom_name.value = f_names[2]
                      module.high_high_custom_name.value = f_names[3]
                  else:
                      f_names = (
                          "Measurement1_low_Measurement2_low",
                          "Measurement1_low_Measurement2_high",
                          "Measurement1_high_Measurement2_low",
                          "Measurement1_high_Measurement2_high",
                      )
                  m_names = [
                      "_".join(
                          (
                              cellprofiler.modules.classifyobjects.M_CATEGORY,
                              name,
                          )
                      )
                      for name in f_names
                  ]
  
                  module.run(workspace)
                  columns = module.get_measurement_columns(None)
                  for column in columns:
                      if column[0] != OBJECTS_NAME:  # Must be image
                          assert column[0] == "Image"
                          assert (
                              column[2] == COLTYPE_INTEGER
                              if column[1].endswith(
                                  cellprofiler.modules.classifyobjects.F_NUM_PER_BIN
                              )
                              else COLTYPE_FLOAT
                          )
                      else:
                          assert column[0] == OBJECTS_NAME
                          assert column[2] == COLTYPE_INTEGER
  
                  assert len(columns) == 12
                  assert (
                      len(set([column[1] for column in columns])) == 12
                  )  # no duplicates
  
                  categories = module.get_categories(None, "Image")
                  assert len(categories) == 1
                  categories = module.get_categories(None, OBJECTS_NAME)
                  assert len(categories) == 1
                  assert (
                      categories[0]
                      == cellprofiler.modules.classifyobjects.M_CATEGORY
                  )
                  names = module.get_measurements(
                      None, OBJECTS_NAME, "foo"
                  )
                  assert len(names) == 0
                  names = module.get_measurements(
                      None,
                      "foo",
                      cellprofiler.modules.classifyobjects.M_CATEGORY,
                  )
                  assert len(names) == 0
                  names = module.get_measurements(
                      None,
                      OBJECTS_NAME,
                      cellprofiler.modules.classifyobjects.M_CATEGORY,
                  )
                  assert len(names) == 4
  
                  for m_name, expected in zip(
                      m_names,
                      (
                          (~m1_over) & (~m2_over),
                          (~m1_over) & m2_over,
                          m1_over & ~m2_over,
                          m1_over & m2_over,
                      ),
                  ):
                      m = workspace.measurements.get_current_measurement(
                          "Image",
                          "_".join(
                              (
                                  m_name,
                                  cellprofiler.modules.classifyobjects.F_NUM_PER_BIN,
                              )
                          ),
                      )
                      assert m == expected.astype(int).sum()
                      m = workspace.measurements.get_current_measurement(
                          "Image",
                          "_".join(
                              (
                                  m_name,
                                  cellprofiler.modules.classifyobjects.F_PCT_PER_BIN,
                              )
                          ),
                      )
                      assert (
                          m
                          == 100.0
                          * float(expected.astype(int).sum())
                          / num_labels
                      )
                      m = workspace.measurements.get_current_measurement(
                          OBJECTS_NAME, m_name
                      )
                      assert numpy.all(m == expected.astype(int))
                      assert m_name in [column[1] for column in columns]
                      assert m_name in [
                          "_".join(
                              (
                                  cellprofiler.modules.classifyobjects.M_CATEGORY,
                                  name,
                              )
                          )
                          for name in names
                      ]
                  image = workspace.image_set.get_image(
                      IMAGE_NAME
                  ).pixel_data
                  assert numpy.all(image[labels == 0, :] == 0)
                  colors = image[(labels > 0) & (m[labels - 1] == 1), :]
                  if colors.shape[0] > 0:
                      assert all(
                          [
                              numpy.all(colors[:, i] == colors[0, i])
                              for i in range(3)
                          ]
                      )
  
imports: import contextlib
  import os
  import pickle
  import tempfile
  import numpy
  import pytest
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  from cellprofiler_core.constants.measurement import COLTYPE_FLOAT, COLTYPE_INTEGER
  import cellprofiler.modules.classifyobjects
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.setting
  import cellprofiler_core.workspace
label_desc: Use image node_id 9 for calling a global function with example usage: test_two() and returns: numpy, numpy, custom_cutoff