code: def from_repo(
      cls,
      repo: "Repo",
      onerror: Optional[Callable[[str, Exception], None]] = None,
  ) -> "Index":
      stages = []
      metrics = {}
      plots = {}
      params = {}
      artifacts = {}
  
      onerror = onerror or repo.stage_collection_error_handler
      for _, idx in collect_files(repo, onerror=onerror):
          stages.extend(idx.stages)
          metrics.update(idx._metrics)
          plots.update(idx._plots)
          params.update(idx._params)
          artifacts.update(idx._artifacts)
      return cls(
          repo,
          stages=stages,
          metrics=metrics,
          plots=plots,
          params=params,
          artifacts=artifacts,
      )
  
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 4 for calling the Index obj's underlying member method code with example usage: obj.from_repo(cls, repo, onerror) and returns: cls