code: def get_nccl_dirs(
      build_ext, cuda_include_dirs, cuda_lib_dirs, cpp_flags
  ):
      nccl_include_dirs = []
      nccl_lib_dirs = []
      nccl_libs = []
  
      nccl_home = os.environ.get("BLUEFOG_NCCL_HOME")
      if nccl_home:
          nccl_include_dirs += ["%s/include" % nccl_home]
          nccl_lib_dirs += [
              "%s/lib" % nccl_home,
              "%s/lib64" % nccl_home,
          ]
  
      nccl_include = os.environ.get("BLUEFOG_NCCL_INCLUDE")
      if nccl_include:
          nccl_include_dirs += [nccl_include]
  
      nccl_lib = os.environ.get("BLUEFOG_NCCL_LIB")
      if nccl_lib:
          nccl_lib_dirs += [nccl_lib]
  
      nccl_link_mode = os.environ.get("BLUEFOG_NCCL_LINK", "STATIC")
      if nccl_link_mode.upper() == "SHARED":
          nccl_libs += ["nccl"]
      else:
          nccl_libs += ["nccl_static"]
  
      try:
          test_compile(
              build_ext,
              "test_nccl",
              libraries=nccl_libs,
              include_dirs=nccl_include_dirs + cuda_include_dirs,
              library_dirs=nccl_lib_dirs + cuda_lib_dirs,
              extra_compile_preargs=cpp_flags,
              code=textwrap.dedent(
                  """\
              #include <nccl.h>
              #if NCCL_MAJOR < 2
              #error BLUEFOG requires NCCL 2.4 or later version, please upgrade.
              #endif
              #if NCCL_MINOR < 4
              #error BLUEFOG requires NCCL 2.4 or later version, please upgrade.
              #endif
              void test() {
                  ncclUniqueId nccl_id;
                  ncclGetUniqueId(&nccl_id);
              }
              """
              ),
          )
      except (CompileError, LinkError):
          raise DistutilsPlatformError(
              "NCCL 2.4 library or its later version was not found (see error above).\n"
              "Please specify correct NCCL location with the BLUEFOG_NCCL_HOME "
              "environment variable or combination of BLUEFOG_NCCL_INCLUDE and "
              "BLUEFOG_NCCL_LIB environment variables.\n\n"
              "BLUEFOG_NCCL_HOME - path where NCCL include and lib directories can be found\n"
              "BLUEFOG_NCCL_INCLUDE - path to NCCL include directory\n"
              "BLUEFOG_NCCL_LIB - path to NCCL lib directory"
          )
  
      return nccl_include_dirs, nccl_lib_dirs, nccl_libs
  
imports: import copy
  import os
  import re
  import shlex
  import subprocess
  import sys
  import textwrap
  import shlex
  import traceback
  from typing import List
  from distutils.errors import CompileError, DistutilsError, DistutilsPlatformError, DistutilsSetupError, LinkError
  from distutils.version import LooseVersion
  from setuptools import find_packages, setup, Extension
  from setuptools.command.build_ext import build_ext
  from bluefog import __version__
label_desc: Use image node_id 8 for calling a global function with example usage: get_nccl_dirs(build_ext, cuda_include_dirs, cuda_lib_dirs, cpp_flags) and returns: nccl_include_dirs,  nccl_lib_dirs,  nccl_libs