code: def make_workspace(image, labels):
      module = cellprofiler.modules.definegrid.DefineGrid()
      module.set_module_num(1)
      module.grid_image.value = GRID_NAME
      module.manual_image.value = INPUT_IMAGE_NAME
      module.display_image_name.value = INPUT_IMAGE_NAME
      module.object_name.value = OBJECTS_NAME
      module.save_image_name.value = OUTPUT_IMAGE_NAME
      image_set_list = cellprofiler_core.image.ImageSetList()
      image_set = image_set_list.get_image_set(0)
      image_set.add(
          INPUT_IMAGE_NAME, cellprofiler_core.image.Image(image)
      )
      object_set = cellprofiler_core.object.ObjectSet()
      objects = cellprofiler_core.object.Objects()
      objects.segmented = labels
      object_set.add_objects(objects, OBJECTS_NAME)
      pipeline = cellprofiler_core.pipeline.Pipeline()
  
      def callback(caller, event):
          assert not isinstance(
              event, cellprofiler_core.pipeline.event.LoadException
          )
          assert not isinstance(
              event, cellprofiler_core.pipeline.event.RunException
          )
  
      pipeline.add_listener(callback)
      pipeline.add_module(module)
      measurements = cellprofiler_core.measurement.Measurements()
      workspace = cellprofiler_core.workspace.Workspace(
          pipeline,
          module,
          image_set,
          object_set,
          measurements,
          image_set_list,
      )
      return workspace, module
  
file_path: CellProfiler/tests/frontend/modules/test_definegrid.py
imports: import numpy
  import pytest
  import cellprofiler_core.utilities.grid
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler.modules.definegrid
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.workspace
label_desc: Use image node_id 1 for calling a global function with example usage: make_workspace(image, labels) and returns: workspace,  module