code: def check_links(links):
      errors = []
      srcs = set()
      dsts = {}
      for l in links:
          srcs.add(l.src)
          dsts.setdefault(l.dst, []).append(l.dst)
          if not doc_exists(l.dst):
              errors.append(f"broken redirect detected: {l}")
          if doc_exists(l.src):
              errors.append(f"redirect shadows an actual file: {l}")
  
      for path in srcs.intersection(set(dsts)):
          errors.append(
              f"multi-layer redirect detected, {l} points to another redirection"
          )
  
      return errors
  
file_path: determined/docs/redirects.py
imports: import argparse
  import collections
  import itertools
  import json
  import os
  import pathlib
  import subprocess
  import sys
label_desc: Use image node_id 3 for calling a global function with example usage: check_links(links) and returns: errors