code: def make_workspace(
      scheme, images, adjustments=None, colors=None, weights=None
  ):
      module = cellprofiler.modules.graytocolor.GrayToColor()
      module.scheme_choice.value = scheme
      module.wants_rescale.value = False
      if scheme not in (
          cellprofiler.modules.graytocolor.SCHEME_COMPOSITE,
          cellprofiler.modules.graytocolor.SCHEME_STACK,
      ):
          image_names = [
              "image%d" % i
              if images[i] is not None
              else cellprofiler.modules.graytocolor.LEAVE_THIS_BLACK
              for i in range(7)
          ]
          for (
              image_name_setting,
              image_name,
              adjustment_setting,
              adjustment,
          ) in zip(
              (
                  module.red_image_name,
                  module.green_image_name,
                  module.blue_image_name,
                  module.cyan_image_name,
                  module.magenta_image_name,
                  module.yellow_image_name,
                  module.gray_image_name,
              ),
              image_names,
              (
                  module.red_adjustment_factor,
                  module.green_adjustment_factor,
                  module.blue_adjustment_factor,
                  module.cyan_adjustment_factor,
                  module.magenta_adjustment_factor,
                  module.yellow_adjustment_factor,
                  module.gray_adjustment_factor,
              ),
              adjustments,
          ):
              image_name_setting.value = image_name
              adjustment_setting.value = adjustment
      else:
          while len(module.stack_channels) < len(images):
              module.add_stack_channel_cb()
          image_names = []
          if weights is None:
              weights = [1.0] * len(images)
          if colors is None:
              colors = [
                  cellprofiler.modules.graytocolor.DEFAULT_COLORS[
                      i
                      % len(
                          cellprofiler.modules.graytocolor.DEFAULT_COLORS
                      )
                  ]
                  for i in range(len(images))
              ]
          for i, (image, color, weight) in enumerate(
              zip(images, colors, weights)
          ):
              image_name = "image%d" % (i + 1)
              image_names.append(image_name)
              module.stack_channels[i].image_name.value = image_name
              module.stack_channels[i].color.value = color
              module.stack_channels[i].weight.value = weight
  
      module.rgb_image_name.value = OUTPUT_IMAGE_NAME
      module.set_module_num(1)
      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)
      image_set_list = cellprofiler_core.image.ImageSetList()
      image_set = image_set_list.get_image_set(0)
      for image, image_name in zip(images, image_names):
          if image is not None:
              image_set.add(
                  image_name, cellprofiler_core.image.Image(image)
              )
      workspace = cellprofiler_core.workspace.Workspace(
          pipeline,
          module,
          image_set,
          cellprofiler_core.object.ObjectSet(),
          cellprofiler_core.measurement.Measurements(),
          image_set_list,
      )
      return workspace, module
  
file_path: CellProfiler/tests/frontend/modules/test_graytocolor.py
imports: import numpy
  import six.moves
  import os
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler.modules.graytocolor
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.workspace
  import tests.frontend.modules
label_desc: Use image node_id 1 for calling a global function with example usage: make_workspace(scheme, images, adjustments, colors, weights) and returns: workspace,  module