code: def test_remove_stage_on_lockfile_format_error(
      tmp_dir, dvc, run_copy
  ):
      tmp_dir.gen("foo", "foo")
      stage = run_copy("foo", "bar", name="copy-foo-bar")
      dvc_file = load_file(dvc, stage.path)
      lock_file = dvc_file._lockfile
  
      data = dvc_file._load()[0]
      lock_data = lock_file.load()
      lock_data["gibberish"] = True
      data["gibberish"] = True
      (tmp_dir / lock_file.relpath).dump(lock_data)
      with pytest.raises(YAMLValidationError):
          dvc_file.remove_stage(stage)
  
      lock_file.remove()
      dvc_file.dump(stage, update_pipeline=False)
  
      (tmp_dir / dvc_file.relpath).dump(data)
      with pytest.raises(YAMLValidationError):
          dvc_file.remove_stage(stage)
  
imports: import textwrap
  import pytest
  from dvc.annotations import Annotation
  from dvc.dvcfile import LOCK_FILE, PROJECT_FILE, ParametrizedDumpError, SingleStageFile, load_file
  from dvc.stage.exceptions import StageFileDoesNotExistError
  from dvc.stage.loader import StageNotFound
  from dvc.utils.strictyaml import YAMLValidationError
label_desc: Use image node_id 13 for calling a global function with example usage: test_remove_stage_on_lockfile_format_error(tmp_dir, dvc, run_copy) without return types