code: def main():
      parser = argparse.ArgumentParser(
          description="Usage for copyright header insertion script"
      )
      parser.add_argument(
          "--dir",
          help="Path to source files to add copyright header to. Will recurse through subdirectories",
          required=True,
          type=str,
      )
      args = parser.parse_args()
  
      current_year = int(datetime.today().year)
      starting_year = 2020
      python_header_path = "tests/py_cprheader.txt"
      with open(python_header_path, "r", encoding="utf-8") as original:
          pyheader = original.read().split("\n")
          pyheader_lines = len(pyheader)
  
      problematic_files = []
  
      for filename in Path(args.dir).rglob("*.py"):
          if str(filename) in EXCLUSIONS:
              continue
          with open(str(filename), "r", encoding="utf-8") as original:
              data = original.readlines()
  
          data = get_top_comments(data)
          if len(data) < pyheader_lines:
              print(
                  f"{filename} has less header lines than the copyright template"
              )
              problematic_files.append(filename)
              continue
  
          found = False
          for i, line in enumerate(data):
              if re.search(
                  re.compile("Copyright.*NVIDIA.*", re.IGNORECASE), line
              ):
                  # if re.search(re.compile("Copyright.*", re.IGNORECASE), line):
                  found = True
                  # Check 1st line manually
                  year_good = False
                  for year in range(starting_year, current_year + 1):
                      year_line = pyheader[0].format(CURRENT_YEAR=year)
                      if year_line in data[i]:
                          year_good = True
                          break
                      year_line_aff = year_line.split(".")
                      year_line_aff = (
                          year_line_aff[0]
                          + " & AFFILIATES."
                          + year_line_aff[1]
                      )
                      if year_line_aff in data[i]:
                          year_good = True
                          break
                  if not year_good:
                      problematic_files.append(filename)
                      print(f"{filename} had an error with the year")
                      break
                  while "opyright" in data[i]:
                      i += 1
                  for j in range(1, pyheader_lines):
                      if pyheader[j] not in data[i + j - 1]:
                          problematic_files.append(filename)
                          print(
                              f"{filename} missed the line: {pyheader[j]}"
                          )
                          break
              if found:
                  break
          if not found:
              print(
                  f"{filename} did not match the regex: `Copyright.*NVIDIA.*`"
              )
              problematic_files.append(filename)
  
      if len(problematic_files) > 0:
          print(
              "check_copyright_headers.py found the following files that might not have a copyright header:"
          )
          for _file in problematic_files:
              print(_file)
          sys.exit(1)
  
imports: import argparse
  import re
  import sys
  from datetime import datetime
  from pathlib import Path
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types