code: def test_checkout_relink(tmp_dir, dvc, link, link_test_func):
      dvc.cache.local.cache_types = [link]
  
      tmp_dir.dvc_gen({"dir": {"data": "text"}})
  
      data_file = os.path.join("dir", "data")
  
      # NOTE: Windows symlink perms don't propagate to the target
      if not (os.name == "nt" and link == "symlink"):
          assert not os.access(data_file, os.W_OK)
  
      dvc.unprotect(data_file)
      assert os.access(data_file, os.W_OK)
      assert not link_test_func(data_file)
  
      stats = dvc.checkout(["dir.dvc"], relink=True)
      assert stats == empty_checkout
      assert link_test_func(data_file)
  
      # NOTE: Windows symlink perms don't propagate to the target and
      # hardlink was chmod-ed during relink to be deleted
      if not (os.name == "nt" and link in ["symlink", "hardlink"]):
          assert not os.access(data_file, os.W_OK)
  
imports: import logging
  import os
  import shutil
  import stat
  import textwrap
  import pytest
  from dvc.cli import main
  from dvc.dvcfile import PROJECT_FILE, load_file
  from dvc.exceptions import CheckoutError, CheckoutErrorSuggestGit, NoOutputOrStageError
  from dvc.fs import system
  from dvc.stage.exceptions import StageFileDoesNotExistError
  from dvc.utils import relpath
  from dvc.utils.fs import remove
  from tests.utils import get_gitignore_content
label_desc: Use image node_id 18 for calling a global function with example usage: test_checkout_relink(tmp_dir, dvc, link, link_test_func) without return types