code: def check_rpackage(path: str) -> None:
      env = os.environ.copy()
      print("Ncpus:", f"{os.cpu_count()}")
      threshold = 2.5
      env.update(
          {
              "MAKEFLAGS": f"-j{os.cpu_count()}",
              # cran specific environment variables
              "_R_CHECK_EXAMPLE_TIMING_CPU_TO_ELAPSED_THRESHOLD_": str(
                  threshold
              ),
              "_R_CHECK_TEST_TIMING_CPU_TO_ELAPSED_THRESHOLD_": str(
                  threshold
              ),
              "_R_CHECK_VIGNETTE_TIMING_CPU_TO_ELAPSED_THRESHOLD_": str(
                  threshold
              ),
          }
      )
  
      # Actually we don't run this check on windows due to dependency issue.
      if system() == "Windows":
          # make sure compiler from rtools is used.
          mingw_bin = get_mingw_bin()
          CXX = os.path.join(mingw_bin, "g++.exe")
          CC = os.path.join(mingw_bin, "gcc.exe")
          env.update({"CC": CC, "CXX": CXX})
  
      status = subprocess.run(
          [R, "CMD", "check", "--as-cran", "--timings", path], env=env
      )
      rcheck_dir = Path("xgboost.Rcheck")
      with open(rcheck_dir / "00check.log", "r") as fd:
          check_log = fd.read()
  
      with open(rcheck_dir / "00install.out", "r") as fd:
          install_log = fd.read()
  
      msg = f"""
  ----------------------- Install ----------------------
  {install_log}
  
  -----------------------  Check -----------------------
  {check_log}
  
      """
  
      if status.returncode != 0:
          print(msg)
          raise ValueError("Failed r package check.")
  
      if check_log.find("WARNING") != -1:
          print(msg)
          raise ValueError("Has unresolved warnings.")
      if check_log.find("Examples with CPU time") != -1:
          print(msg)
          raise ValueError("Suspicious NOTE.")
      if pd is not None:
          check_example_timing(rcheck_dir, threshold)
  
file_path: xgboost/tests/ci_build/test_r_package.py
imports: import argparse
  import os
  import shutil
  import subprocess
  from io import StringIO
  from pathlib import Path
  from platform import system
  from test_utils import R_PACKAGE, ROOT, DirectoryExcursion, cd, print_time, record_time
label_desc: Use image node_id 5 for calling a global function with example usage: check_rpackage(path) without return types