code: def test_foreach_data_from_nested_vars(tmp_dir, dvc):
      vars_ = {"models": {"lst": [{"thresh": 10}, {"thresh": 15}]}}
      resolver = DataResolver(dvc, tmp_dir.fs_path, {"vars": [vars_]})
      data = {
          "foreach": "${models.lst}",
          "do": {"cmd": "echo ${item.thresh}"},
      }
      definition = ForeachDefinition(
          resolver, resolver.context, "build", data
      )
  
      assert definition.resolve_all() == {
          "build@0": {"cmd": "echo 10"},
          "build@1": {"cmd": "echo 15"},
      }
      assert resolver.context == vars_
      assert not any(item for item in resolver.tracked_vars.values())
  
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 9 for calling a global function with example usage: test_foreach_data_from_nested_vars(tmp_dir, dvc) without return types