code: def configure_extension_modules():
      # Skip cythonization as we do not want to include the generated
      # C/C++ files in the release tarballs as they are not necessarily
      # forward compatible with future versions of Python for instance.
      if "sdist" in sys.argv or "--help" in sys.argv:
          return []
  
      import numpy
  
      from sklearn._build_utils import (
          cythonize_extensions,
          gen_from_templates,
      )
  
      is_pypy = platform.python_implementation() == "PyPy"
      np_include = numpy.get_include()
      default_optimization_level = "O2"
  
      if os.name == "posix":
          default_libraries = ["m"]
      else:
          default_libraries = []
  
      default_extra_compile_args = []
      build_with_debug_symbols = (
          os.environ.get("SKLEARN_BUILD_ENABLE_DEBUG_SYMBOLS", "0")
          != "0"
      )
      if os.name == "posix":
          if build_with_debug_symbols:
              default_extra_compile_args.append("-g")
          else:
              # Setting -g0 will strip symbols, reducing the binary size of extensions
              default_extra_compile_args.append("-g0")
  
      cython_exts = []
      for submodule, extensions in extension_config.items():
          submodule_parts = submodule.split(".")
          parent_dir = join("sklearn", *submodule_parts)
          for extension in extensions:
              if is_pypy and not extension.get(
                  "compile_for_pypy", True
              ):
                  continue
  
              # Generate files with Tempita
              tempita_sources = []
              sources = []
              for source in extension["sources"]:
                  source = join(parent_dir, source)
                  new_source_path, path_ext = os.path.splitext(source)
  
                  if path_ext != ".tp":
                      sources.append(source)
                      continue
  
                  # `source` is a Tempita file
                  tempita_sources.append(source)
  
                  # Only include source files that are pyx files
                  if os.path.splitext(new_source_path)[-1] == ".pyx":
                      sources.append(new_source_path)
  
              gen_from_templates(tempita_sources)
  
              # Do not progress if we only have a tempita file which we don't
              # want to include like the .pxi.tp extension. In such a case
              # sources would be empty.
              if not sources:
                  continue
  
              # By convention, our extensions always use the name of the first source
              source_name = os.path.splitext(
                  os.path.basename(sources[0])
              )[0]
              if submodule:
                  name_parts = ["sklearn", submodule, source_name]
              else:
                  name_parts = ["sklearn", source_name]
              name = ".".join(name_parts)
  
              # Make paths start from the root directory
              include_dirs = [
                  join(parent_dir, include_dir)
                  for include_dir in extension.get("include_dirs", [])
              ]
              if extension.get("include_np", False):
                  include_dirs.append(np_include)
  
              depends = [
                  join(parent_dir, depend)
                  for depend in extension.get("depends", [])
              ]
  
              extra_compile_args = (
                  extension.get("extra_compile_args", [])
                  + default_extra_compile_args
              )
              optimization_level = extension.get(
                  "optimization_level", default_optimization_level
              )
              if os.name == "posix":
                  extra_compile_args.append(f"-{optimization_level}")
              else:
                  extra_compile_args.append(f"/{optimization_level}")
  
              libraries_ext = (
                  extension.get("libraries", []) + default_libraries
              )
  
              new_ext = Extension(
                  name=name,
                  sources=sources,
                  language=extension.get("language", None),
                  include_dirs=include_dirs,
                  libraries=libraries_ext,
                  depends=depends,
                  extra_link_args=extension.get(
                      "extra_link_args", None
                  ),
                  extra_compile_args=extra_compile_args,
              )
              cython_exts.append(new_ext)
  
      return cythonize_extensions(cython_exts)
  
imports: import importlib
  import os
  import platform
  import shutil
  import sys
  import traceback
  from os.path import join
  from setuptools import Command, Extension, setup
  from setuptools.command.build_ext import build_ext
  import sklearn
  import sklearn._min_dependencies
  from sklearn._build_utils import _check_cython_version
  from sklearn.externals._packaging.version import parse
label_desc: Use image node_id 2 for calling a global function with example usage: configure_extension_modules() and returns: cythonize_extensions, list