code: def test_combine_channels():
      numpy.random.seed(13)
      image = numpy.random.uniform(size=(20, 10, 5))
      image_set_list = cellprofiler_core.image.ImageSetList()
      image_set = image_set_list.get_image_set(0)
      image_set.add(IMAGE_NAME, cellprofiler_core.image.Image(image))
  
      module = cellprofiler.modules.colortogray.ColorToGray()
      module.set_module_num(1)
      module.image_name.value = IMAGE_NAME
      module.combine_or_split.value = (
          cellprofiler.modules.colortogray.COMBINE
      )
      module.grayscale_name.value = OUTPUT_IMAGE_F % 1
      module.rgb_or_channels.value = (
          cellprofiler.modules.colortogray.CH_CHANNELS
      )
      module.add_channel()
      module.add_channel()
  
      channel_indexes = numpy.array([2, 0, 3])
      factors = numpy.random.uniform(size=3)
      divisor = numpy.sum(factors)
      expected = numpy.zeros((20, 10))
      for i, channel_index in enumerate(channel_indexes):
          module.channels[i].channel_choice.value = channel_index + 1
          module.channels[i].contribution.value_text = (
              "%.10f" % factors[i]
          )
          expected += image[:, :, channel_index] * factors[i] / divisor
  
      pipeline = cellprofiler_core.pipeline.Pipeline()
  
      def callback(caller, event):
          assert not isinstance(
              event, cellprofiler_core.pipeline.event.RunException
          )
  
      pipeline.add_listener(callback)
      pipeline.add_module(module)
      workspace = cellprofiler_core.workspace.Workspace(
          pipeline,
          module,
          image_set,
          cellprofiler_core.object.ObjectSet(),
          cellprofiler_core.measurement.Measurements(),
          image_set_list,
      )
      module.run(workspace)
      pixels = image_set.get_image(
          module.grayscale_name.value
      ).pixel_data
      assert pixels.ndim == 2
      assert tuple(pixels.shape) == (20, 10)
      numpy.testing.assert_almost_equal(expected, pixels)
  
imports: import numpy
  import pytest
  import six.moves
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler.modules.colortogray
  import cellprofiler_core.modules.injectimage
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.workspace
  import tests.frontend.modules
label_desc: Use image node_id 5 for calling a global function with example usage: test_combine_channels() without return types