code: def check_import(file):
      check_to_lines = {
          "import ray": -1,
          "import psutil": -1,
          "import setproctitle": -1,
      }
  
      with io.open(file, "r", encoding="utf-8") as f:
          for i, line in enumerate(f):
              for check in check_to_lines.keys():
                  # This regex will match the following case
                  # - the string itself: `import psutil`
                  # - white space/indentation + the string:`    import psutil`
                  # - the string and arbitrary whitespace: `import psutil    `
                  # - the string and the noqa flag to silent pylint
                  #   `import psutil # noqa F401 import-ordering`
                  # It will not match the following
                  # - submodule import: `import ray.constants as ray_constants`
                  # - submodule import: `from ray import xyz`
                  if (
                      re.search(
                          r"^\s*" + check + r"(\s*|\s+# noqa F401.*)$",
                          line,
                      )
                      and check_to_lines[check] == -1
                  ):
                      check_to_lines[check] = i
  
      for import_lib in ["import psutil", "import setproctitle"]:
          if check_to_lines[import_lib] != -1:
              import_psutil_line = check_to_lines[import_lib]
              import_ray_line = check_to_lines["import ray"]
              if (
                  import_ray_line == -1
                  or import_ray_line > import_psutil_line
              ):
                  print(
                      "{}:{}".format(str(file), import_psutil_line + 1),
                      "{} without explicitly import ray before it.".format(
                          import_lib
                      ),
                  )
                  global exit_with_error
                  exit_with_error = True
  
imports: import argparse
  import glob
  import io
  import re
  import sys
  from pathlib import Path
label_desc: Use image node_id 1 for calling a global function with example usage: check_import(file) without return types