from typing import Optional


def _symbol_mash(base_symbol: str, ds_symbol: Optional[int]) -> int:
    """Compute a composite symbol id given 2 symbol components.

    A list of the normally possible symbols can be found here: https://plotly.com/python/marker-style/

    Args:
        base_symbol: The symbol to be put on the bottom.
        ds_symbol: The symbol to be drawn over the base_symbol.

    Returns:
        An integer corresponding to the shape which we will override to be the overlaid shape.
    """
    base_table = {'circle': 0, 'diamond': 2, 'square': 1, 'hexagram': 18}
    if ds_symbol is None:
        return base_table[base_symbol]
    ds_offsets = {37: 0, 38: 1, 39: 2, 40: 3, 34: 4, 33: 5, 35: 6, 36: 7}
    slots = {i for i in range(53)} - set(base_table.values()) - set(ds_offsets.keys())
    slots = sorted(list(slots))
    base_offsets = {'circle': 0,
                    'diamond': len(ds_offsets),
                    'square': 2 * len(ds_offsets),
                    'hexagram': 3 * len(ds_offsets)}
    mashed_symbol = slots[base_offsets[base_symbol] + ds_offsets[ds_symbol]]
    return mashed_symbol