def hstack(
        cls,
        diagrams: Sequence[cirq.TextDiagramDrawer],
        padding_resolver: Callable[[Sequence[int | None]], int] | None = None,
    ):
        """Horizontally stack text diagrams.

        Args:
            diagrams: The diagrams to stack, ordered from left to right.
            padding_resolver: A function that takes a list of paddings
                specified for a row and returns the padding to use in the
                stacked diagram. Defaults to raising ValueError if the diagrams
                to stack contain inconsistent padding in any row, including
                if some specify a padding and others don't.

        Raises:
            ValueError: Inconsistent padding cannot be resolved.

        Returns:
            The horizontally stacked diagram.
        """

        if padding_resolver is None:
            padding_resolver = _same_element_or_throw_error

        stacked = cls()
        dx = 0
        for diagram in diagrams:
            stacked.superimpose(diagram.shifted(dx=dx))
            dx += diagram.width()
        for y in stacked.vertical_padding:
            resolved_padding = padding_resolver(
                tuple(cast(int | None, diagram.vertical_padding.get(y)) for diagram in diagrams)
            )
            if resolved_padding is not None:
                stacked.vertical_padding[y] = resolved_padding
        return stacked
Horizontally stack text diagrams.

        Args:
            diagrams: The diagrams to stack, ordered from left to right.
            padding_resolver: A function that takes a list of paddings
                specified for a row and returns the padding to use in the
                stacked diagram. Defaults to raising ValueError if the diagrams
                to stack contain inconsistent padding in any row, including
                if some specify a padding and others don't.

        Raises:
            ValueError: Inconsistent padding cannot be resolved.

        Returns:
            The horizontally stacked diagram.
        
cirq-core/cirq/circuits/text_diagram_drawer.py