code: def check_includes_in(
      src, inplace, top_inc_dirs
  ) -> typing.List[Issue]:
      issues: typing.List[Issue] = []
      dir = os.path.dirname(src)
      found_pragma_once = False
      include_count = 0
  
      # Read all lines
      with io.open(src, encoding="utf-8") as file_obj:
          lines = list(enumerate(file_obj))
  
      for line_number, line in lines:
          line_num = line_number + 1
  
          match = IncludeRegex.search(line)
          if match is None:
              # Check to see if its a pragma once
              if not found_pragma_once:
                  pragma_match = PragmaRegex.search(line)
  
                  if pragma_match is not None:
                      found_pragma_once = True
  
                      if include_count > 0:
                          issues.append(
                              Issue(
                                  True,
                                  "`#pragma once` must be before any `#include`",
                                  src,
                                  line_num,
                              )
                          )
              continue
  
          include_count += 1
  
          val_type = match.group(2)  # " or <
          inc_file = match.group(3)
          full_path = os.path.join(dir, inc_file)
  
          if val_type == '"' and not os.path.isfile(full_path):
              new_line, n = IncludeRegex.subn(r"\1<\3>", line)
              assert (
                  n == 1
              ), "inplace only handles one include match per line"
  
              issues.append(
                  Issue(
                      True,
                      "use #include <...>",
                      src,
                      line_num,
                      new_line,
                  )
              )
  
          elif val_type == "<" and os.path.isfile(full_path):
              new_line, n = IncludeRegex.subn(r'\1"\3"', line)
              assert (
                  n == 1
              ), "inplace only handles one include match per line"
  
              issues.append(
                  Issue(
                      True,
                      'use #include "..."',
                      src,
                      line_num,
                      new_line,
                  )
              )
  
          # output warnings for some cases
          # 1. relative include containing current folder
          # 2. relative include going over src / src_prims folders
          # 3. relative include longer than 2 folders and containing
          #    both ".." and "non-.."
          # 4. absolute include used but rel include possible without warning
          if val_type == '"':
              issues += rel_include_warnings(
                  dir, src, line_num, inc_file, top_inc_dirs
              )
          if val_type == "<":
              # try to make a relative import using the top folders
              for top_folder in top_inc_dirs:
                  full_dir = os.path.abspath(dir)
                  fs = full_dir.split(os.path.sep)
                  fs_alt = full_dir.split(os.path.altsep)
                  if len(fs) <= 1:
                      fs = fs_alt
                  if top_folder not in fs:
                      continue
                  if fs[0] == "":  # full dir was absolute
                      fs[0] = os.path.sep
                  full_top = os.path.join(
                      *fs[: fs.index(top_folder) + 1]
                  )
                  full_inc = os.path.join(full_top, inc_file)
                  if not os.path.isfile(full_inc):
                      continue
                  new_rel_inc = os.path.relpath(full_inc, full_dir)
                  warn = rel_include_warnings(
                      dir, src, line_num, new_rel_inc, top_inc_dirs
                  )
                  if len(warn) == 0:
                      issues.append(
                          Issue(
                              False,
                              "absolute include could be transformed to relative",
                              src,
                              line_num,
                              f'#include "{new_rel_inc}"\n',
                          )
                      )
                  else:
                      issues += warn
  
      if inplace and len(issues) > 0:
          had_fixes = False
  
          for issue in issues:
              if issue.fixed_str is not None:
                  lines[issue.line - 1] = (
                      lines[issue.line - 1][0],
                      issue.fixed_str,
                  )
                  issue.was_fixed = True
                  had_fixes = True
  
          if had_fixes:
              with io.open(src, "w", encoding="utf-8") as out_file:
                  for _, new_line in lines:
                      out_file.write(new_line)
  
      return issues
  
file_path: cuml/cpp/scripts/include_checker.py
imports: from __future__ import print_function
  import sys
  import re
  import os
  import argparse
  import io
  from functools import reduce
  import operator
  import dataclasses
  import typing
label_desc: Use image node_id 7 for calling a global function with example usage: check_includes_in(src, inplace, top_inc_dirs) and returns: issues