code: def test_foreach_with_imported_vars(tmp_dir, dvc, local_import):
      (tmp_dir / "params.yaml").dump(
          {"models": {"model1": {"thresh": "foo"}}}
      )
      (tmp_dir / "test_params.yaml").dump(
          {"train": {"epochs": 10}, "prepare": {"nums": 25}}
      )
      resolver = DataResolver(dvc, tmp_dir.fs_path, {})
      foreach_data = ["foo", "bar"]
      data = {
          "foreach": foreach_data,
          "do": {
              "vars": [local_import],
              "cmd": "echo ${item} ${train.epochs}",
          },
      }
      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@foo": {"cmd": "echo foo 10"},
          "build@bar": {"cmd": "echo bar 10"},
      }
  
      assert resolver.context == {
          "models": {"model1": {"thresh": "foo"}}
      }
      assert resolver.tracked_vars == {
          "build@foo": {"test_params.yaml": {"train.epochs": 10}},
          "build@bar": {"test_params.yaml": {"train.epochs": 10}},
      }
  
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 15 for calling a global function with example usage: test_foreach_with_imported_vars(tmp_dir, dvc, local_import) without return types