class_docstr: Container class for storing all linkable elements for a metric.
  
  TODO: There are similarities with LinkableSpecSet - consider consolidation.
docstr: Find the intersection of all elements in the sets by path key.
  
  This is useful to figure out the common dimensions that are possible to query with multiple metrics. You would
  find the LinakbleSpecSet for each metric in the query, then do an intersection of the sets.
docstr_tok: ["Find","the","intersection","of","all","elements","in","the","sets","by","path","key",".","This","is","useful","to","figure","out","the","common","dimensions","that","are","possible","to","query","with","multiple","metrics",".","You","would","find","the","LinakbleSpecSet","for","each","metric","in","the","query",",","then","do","an","intersection","of","the","sets","."]
code: def intersection_by_path_key(
      linkable_element_sets: Sequence[LinkableElementSet],
  ) -> LinkableElementSet:
      """Find the intersection of all elements in the sets by path key.
  
      This is useful to figure out the common dimensions that are possible to query with multiple metrics. You would
      find the LinakbleSpecSet for each metric in the query, then do an intersection of the sets.
      """
      if len(linkable_element_sets) == 0:
          return LinkableElementSet(
              path_key_to_linkable_dimensions={},
              path_key_to_linkable_entities={},
          )
  
      # Find path keys that are common to all LinkableElementSets.
      common_linkable_dimension_path_keys: Set[
          ElementPathKey
      ] = set.intersection(
          *[
              set(
                  linkable_element_set.path_key_to_linkable_dimensions.keys()
              )
              for linkable_element_set in linkable_element_sets
          ]
      )
  
      common_linkable_entity_path_keys: Set[
          ElementPathKey
      ] = set.intersection(
          *[
              set(
                  linkable_element_set.path_key_to_linkable_entities.keys()
              )
              for linkable_element_set in linkable_element_sets
          ]
      )
  
      # Create a new LinkableElementSet that only includes items where the path key is common to all sets.
      join_path_to_linkable_dimensions: Dict[
          ElementPathKey, Set[LinkableDimension]
      ] = defaultdict(set)
      join_path_to_linkable_entities: Dict[
          ElementPathKey, Set[LinkableEntity]
      ] = defaultdict(set)
  
      for linkable_element_set in linkable_element_sets:
          for (
              path_key,
              linkable_dimensions,
          ) in (
              linkable_element_set.path_key_to_linkable_dimensions.items()
          ):
              if path_key in common_linkable_dimension_path_keys:
                  join_path_to_linkable_dimensions[path_key].update(
                      linkable_dimensions
                  )
          for (
              path_key,
              linkable_entities,
          ) in (
              linkable_element_set.path_key_to_linkable_entities.items()
          ):
              if path_key in common_linkable_entity_path_keys:
                  join_path_to_linkable_entities[path_key].update(
                      linkable_entities
                  )
  
      return LinkableElementSet(
          path_key_to_linkable_dimensions={
              path_key: tuple(
                  sorted(
                      dimensions,
                      key=lambda linkable_dimension: linkable_dimension.semantic_model_origin.semantic_model_name,
                  )
              )
              for path_key, dimensions in join_path_to_linkable_dimensions.items()
          },
          path_key_to_linkable_entities={
              path_key: tuple(
                  sorted(
                      entities,
                      key=lambda linkable_entity: linkable_entity.semantic_model_origin.semantic_model_name,
                  )
              )
              for path_key, entities in join_path_to_linkable_entities.items()
          },
      )
  
imports: from __future__ import annotations
  import logging
  import time
  from collections import defaultdict
  from dataclasses import dataclass
  from typing import Dict, FrozenSet, List, Optional, Sequence, Set, Tuple
  from dbt_semantic_interfaces.enum_extension import assert_values_exhausted
  from dbt_semantic_interfaces.pretty_print import pformat_big_objects
  from dbt_semantic_interfaces.protocols.dimension import Dimension, DimensionType
  from dbt_semantic_interfaces.protocols.semantic_manifest import SemanticManifest
  from dbt_semantic_interfaces.protocols.semantic_model import SemanticModel
  from dbt_semantic_interfaces.references import DimensionReference, MeasureReference, MetricReference, SemanticModelReference, TimeDimensionReference
  from dbt_semantic_interfaces.type_enums import MetricType
  from dbt_semantic_interfaces.type_enums.date_part import DatePart
  from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity
  from metricflow.dataset.dataset import DataSet
  from metricflow.errors.errors import UnknownMetricLinkingError
  from metricflow.model.semantics.linkable_element_properties import LinkableElementProperties
  from metricflow.model.semantics.semantic_model_join_evaluator import SemanticModelJoinEvaluator
  from metricflow.model.semantics.semantic_model_lookup import SemanticModelLookup
  from metricflow.protocols.semantics import SemanticModelAccessor
  from metricflow.specs.specs import DEFAULT_TIME_GRANULARITY, DimensionSpec, EntityReference, EntitySpec, LinkableSpecSet, TimeDimensionSpec
label_desc: Use image node_id 2 for calling the LinkableElementSet obj's underlying member method code with example usage: obj.intersection_by_path_key(linkable_element_sets) and returns: LinkableElementSet, LinkableElementSet