code: def test_batch():
      orig_path = "/foo/bar"
  
      def fn_alter_path(path, **varargs):
          assert path == orig_path
          return "/imaging/analysis"
  
      module = cellprofiler.modules.flagimage.FlagImage()
      rd = module.flags[0].measurement_settings[0].rules_directory
      rd.dir_choice = cellprofiler_core.preferences.ABSOLUTE_FOLDER_NAME
      rd.custom_path = orig_path
      module.prepare_to_create_batch(None, fn_alter_path)
      assert rd.custom_path == "/imaging/analysis"
  
imports: import contextlib
  import os
  import tempfile
  import numpy
  import pytest
  import six.moves
  from cellprofiler_core.constants.measurement import COLTYPE_INTEGER
  from cellprofiler_core.constants.workspace import DISPOSITION_CONTINUE, DISPOSITION_SKIP
  import tests.frontend.modules
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler.modules.flagimage
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.preferences
  import cellprofiler_core.setting
  import cellprofiler_core.workspace
  from .None import test_filterobjects
label_desc: Use image node_id 28 for calling a global function with example usage: test_batch() and returns: str