code: def test_cached_metrics(tmp_dir, dvc, scm, remote):
      tmp_dir.dvc_gen(
          {
              "dir": {"metrics.yaml": "foo: 3\nbar: 10"},
              "dir2": {"metrics.yaml": "foo: 42\nbar: 4"},
          }
      )
      dvc.push()
      dvc.cache.local.clear()
  
      (tmp_dir / "dvc.yaml").dump(
          {"metrics": ["dir/metrics.yaml", "dir2"]}
      )
  
      assert dvc.metrics.show() == {
          "": {
              "data": {
                  join("dir", "metrics.yaml"): {
                      "data": {"foo": 3, "bar": 10}
                  },
                  join("dir2", "metrics.yaml"): {
                      "data": {"foo": 42, "bar": 4}
                  },
              }
          }
      }
  
imports: import json
  import os
  from os.path import join
  import pytest
  from funcy import get_in
  from dvc.cli import main
  from dvc.dvcfile import PROJECT_FILE
  from dvc.exceptions import OverlappingOutputPathsError
  from dvc.repo import Repo
  from dvc.utils.fs import remove
  from dvc.utils.serialize import JSONFileCorruptedError
label_desc: Use image node_id 20 for calling a global function with example usage: test_cached_metrics(tmp_dir, dvc, scm, remote) without return types