code: def test_foreach_with_interpolated_wdir_and_local_vars(
      tmp_dir, dvc, local_import
  ):
      (tmp_dir / "params.yaml").dump(
          {"models": {"model1": {"thresh": "foo"}}}
      )
  
      for i in range(5):
          build_dir = tmp_dir / ("model-" + str(i))
          build_dir.mkdir()
          (build_dir / "params.yaml").dump(
              {"train": {"epochs": 1 + i}, "prepare": {"nums": 10 * i}},
          )
  
      resolver = DataResolver(dvc, tmp_dir.fs_path, {})
      data = {
          "foreach": [0, 1, 2, 3, 4],
          "do": {
              "wdir": "model-${item}",
              "vars": [local_import],
              "cmd": "echo ${item} ${train.epochs} ${prepare.nums}",
          },
      }
      definition = ForeachDefinition(
          resolver, resolver.context, "build", data
      )
  
      assert definition.resolve_all() == {
          # note that the resolver generates `wdir` relative to file's wdir
          # so, this is just `foo`, not `data/foo`.
          # figuring out `wdir` is the responsibility of the `load_stage`/`Stage`
          "build@0": {"wdir": "model-0", "cmd": "echo 0 1 0"},
          "build@1": {"wdir": "model-1", "cmd": "echo 1 2 10"},
          "build@2": {"wdir": "model-2", "cmd": "echo 2 3 20"},
          "build@3": {"wdir": "model-3", "cmd": "echo 3 4 30"},
          "build@4": {"wdir": "model-4", "cmd": "echo 4 5 40"},
      }
  
      assert resolver.context == {
          "models": {"model1": {"thresh": "foo"}}
      }
      assert resolver.tracked_vars == {
          "build@0": {
              os.path.join("model-0", "params.yaml"): {
                  "train.epochs": 1,
                  "prepare.nums": 0,
              }
          },
          "build@1": {
              os.path.join("model-1", "params.yaml"): {
                  "train.epochs": 2,
                  "prepare.nums": 10,
              }
          },
          "build@2": {
              os.path.join("model-2", "params.yaml"): {
                  "train.epochs": 3,
                  "prepare.nums": 20,
              }
          },
          "build@3": {
              os.path.join("model-3", "params.yaml"): {
                  "train.epochs": 4,
                  "prepare.nums": 30,
              }
          },
          "build@4": {
              os.path.join("model-4", "params.yaml"): {
                  "train.epochs": 5,
                  "prepare.nums": 40,
              }
          },
      }
      assert resolver.context.imports == {DEFAULT_PARAMS_FILE: None}
  
imports: import os
  import pytest
  from dvc.parsing import DEFAULT_PARAMS_FILE, DataResolver, ForeachDefinition
  from dvc.parsing.context import Context
label_desc: Use image node_id 16 for calling a global function with example usage: test_foreach_with_interpolated_wdir_and_local_vars(tmp_dir, dvc, local_import) without return types