code: def get_visited_ids_by_artifact_ids(
      starting_artifact_ids: List[int],
      direction: metadata_store_pb2.LineageSubgraphQueryOptions.Direction,
      graph: metadata_store_pb2.LineageGraph,
      optional_event_filter: Optional[
          Callable[[metadata_store_pb2.Event], bool]
      ] = None,
  ) -> Dict[int, Dict[NodeType, Set[int]]]:
      """Given a list of starting artifacts, retrieve the visited ids explored.
  
      Given a list of starting artifacts, returns a mapping of each artifact id
      and the visited nodes of each dfs derived from it.
  
      Args:
        starting_artifact_ids: starting artifact ids.
        direction: direction of dfs. It can be single-directional or bidirectional.
        graph: the lineage graph to run dfs on.
        optional_event_filter: an optional callable object for filtering events in
          the paths. Only an event with `optional_event_filter(event)` evaluated to
          True will be considered as valid and kept in the path.
  
      Returns:
        Mappings of starting artifact ids and visited ids explored in dfs.
      """
      resolver_graph = _build_resolver_graph(
          graph, optional_event_filter
      )
      artifact_to_visited_ids = collections.defaultdict(
          lambda: collections.defaultdict(set)
      )
      for artifact_id in starting_artifact_ids:
          visited_ids = {
              NodeType.ARTIFACT: set(),
              NodeType.EXECUTION: set(),
          }
          _explore_from_artifact(
              artifact_id,
              direction,
              resolver_graph,
              visited_ids,
              metadata_store_pb2.LineageGraph(),
          )
          artifact_to_visited_ids[artifact_id].update(visited_ids)
      return artifact_to_visited_ids
  
file_path: ml-metadata/ml_metadata/tools/mlmd_resolver/metadata_resolver_utils.py
imports: import collections
  import enum
  from typing import Callable, Dict, List, Optional, Set
  import attr
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 6 for calling a global function with example usage: get_visited_ids_by_artifact_ids(starting_artifact_ids, direction, graph, optional_event_filter) and returns: artifact_to_visited_ids