code: def join(
      lhs: Sequence[Tuple[Partition, _T]],
      rhs: Sequence[Tuple[Partition, _T]],
      merge_fn: Callable[[_T, _T], _T],
  ) -> Sequence[Tuple[Partition, _T]]:
      """Join values by the partition key.
  
      Example:
        join(
            [
                ({x=1, y=1}, 'xy-11'),
                ({x=2, y=2}, 'xy-22'),
            ],
            [
                ({x=1, z=1}, 'xz-11'),
                ({x=1, z=2}, 'xz-12'),
                ({x=2, z=1}, 'xz-21'),
                ({x=2, z=2}, 'xz-22'),
            ],
            merge_fn=lambda left, right: f'{left}_{right}'
        ) == [
            ({x=1, y=1, z=1}, 'xy-11_xz-11'),
            ({x=1, y=1, z=2}, 'xy-11_xz-12'),
            ({x=2, y=2, z=1}, 'xy-22_xz-21'),
            ({x=2, y=2, z=2}, 'xy-22_xz-22'),
        ]
  
      Args:
        lhs: LHS values.
        rhs: RHS values.
        merge_fn: A merge function that is called for each joined pair of values.
  
      Returns:
        A inner-joined value with merged Partition and values.
      """
      if not lhs or not rhs:
          return []
  
      common_dims = sorted(
          set(lhs[0][0].dimensions) & set(rhs[0][0].dimensions)
      )
      lhs_by_part = _group_by(lhs, common_dims)
      rhs_by_part = _group_by(rhs, common_dims)
  
      result = []
      for part, sub_lhs in lhs_by_part.items():
          if part not in rhs_by_part:
              continue
          sub_rhs = rhs_by_part[part]
          for left_partition, left_value in sub_lhs:
              for right_partition, right_value in sub_rhs:
                  merged_partition = left_partition | right_partition
                  merged_value = merge_fn(left_value, right_value)
                  result.append((merged_partition, merged_value))
      return result
  
file_path: tfx/tfx/orchestration/portable/input_resolution/partition_utils.py
imports: import collections
  from typing import Callable, Mapping, Sequence, Tuple, TypeVar
label_desc: Use image node_id 2 for calling a global function with example usage: join(lhs, rhs, merge_fn) and returns: result, list