code: def metric_keys(self) -> Dict[str, Set["DataIndexKey"]]:
      from .metrics.show import _collect_top_level_metrics
  
      by_workspace: Dict[str, Set["DataIndexKey"]] = defaultdict(set)
  
      by_workspace["repo"] = set()
  
      for out in self.outs:
          if not out.metric:
              continue
  
          workspace, key = out.index_key
          by_workspace[workspace].add(key)
  
      for path in _collect_top_level_metrics(self.repo):
          key = self.repo.fs.relparts(path, self.repo.root_dir)
          by_workspace["repo"].add(key)
  
      return dict(by_workspace)
  
imports: import logging
  import time
  from collections import defaultdict
  from functools import partial
  from itertools import chain
  from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, Iterator, List, NamedTuple, Optional, Set, Tuple, Union
  from funcy.debug import format_time
  from dvc.dependency import ParamsDependency
  from dvc.fs import LocalFileSystem
  from dvc.fs.callbacks import DEFAULT_CALLBACK
  from dvc.log import logger
  from dvc.utils.objects import cached_property
label_desc: Use image node_id 20 for calling the Index obj's underlying member method code with example usage: obj.metric_keys() and returns: dict