code: def test_item_key_in_generated_stage_vars(
      tmp_dir, dvc, redefine, from_file
  ):
      context = Context(foo="bar")
      vars_ = [redefine]
      if from_file:
          (tmp_dir / "test_params.yaml").dump(redefine)
          vars_ = ["test_params.yaml"]
  
      definition = make_foreach_def(
          tmp_dir,
          "build",
          {"model1": {"thresh": "10"}, "model2": {"thresh": 5}},
          {"vars": vars_, "cmd": "${item}"},
          context,
      )
  
      with pytest.raises(ResolveError) as exc_info:
          definition.resolve_all()
  
      message = str(exc_info.value)
      assert (
          "failed to parse stage 'build@model1' in 'dvc.yaml': "
          "attempted to modify reserved" in message
      )
  
      key_or_keys = "keys" if len(redefine) > 1 else "key"
      assert f"{key_or_keys} {join(redefine)}" in message
      if from_file:
          assert "in 'test_params.yaml'" in message
      assert context == {"foo": "bar"}
  
imports: import logging
  import re
  import pytest
  from dvc.parsing import ResolveError
  from dvc.parsing.context import Context
  from dvc.parsing.interpolate import embrace
  from dvc.utils.humanize import join
  from .None import make_entry_definition, make_foreach_def
label_desc: Use image node_id 16 for calling a global function with example usage: test_item_key_in_generated_stage_vars(tmp_dir, dvc, redefine, from_file) without return types