code: def collapse_fixtures(fixtures, pattern, repl, globals_, idfunc=None):
      """Create unions of fixtures based on specific name mappings.
  
      `fixtures` are grouped into unions according the regex replacement
      `re.sub(pattern, repl)` and placed into `new_fixtures`.
      """
  
      def collapser(n):
          return re.sub(pattern, repl, n)
  
      # Note: sorted creates a new list, not a view, so it's OK to modify the
      # list of fixtures while iterating over the sorted result.
      for name, group in groupby(
          sorted(fixtures, key=collapser), key=collapser
      ):
          group = list(group)
          if len(group) > 1 and name not in fixtures:
              pytest_cases.fixture_union(
                  name=name, fixtures=group, ids=idfunc
              )
              # Need to assign back to the parent scope's globals.
              globals_[name] = globals()[name]
              fixtures.add(name)
  
imports: import inspect
  import re
  import textwrap
  from collections.abc import MutableSet
  from itertools import groupby
  from numbers import Real
  import pytest_cases
  from config import NUM_COLS, NUM_ROWS, cudf, cupy
label_desc: Use image node_id 5 for calling a global function with example usage: collapse_fixtures(fixtures, pattern, repl, globals_, idfunc) and returns: re