code: def test_checkout_stats_on_failure(tmp_dir, dvc, scm):
      tmp_dir.dvc_gen(
          {
              "foo": "foo",
              "dir": {"subdir": {"file": "file"}},
              "other": "other",
          },
          commit="initial",
      )
      stage = load_file(dvc, "foo.dvc").stage
      tmp_dir.dvc_gen(
          {"foo": "foobar", "other": "other other"}, commit="second"
      )
  
      # corrupt cache
      cache = stage.outs[0].cache_path
      os.chmod(cache, 0o644)
      with open(cache, "a", encoding="utf-8") as fd:
          fd.write("destroy cache")
  
      scm.checkout("HEAD~")
      with pytest.raises(CheckoutError) as exc:
          dvc.checkout(force=True)
  
      assert exc.value.stats == {
          **empty_checkout,
          "failed": ["foo"],
          "modified": ["other"],
      }
  
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 22 for calling a global function with example usage: test_checkout_stats_on_failure(tmp_dir, dvc, scm) without return types