def workspace_from_spins(spin_a, spin_b, workspace_spin00, workspace_spin02, workspace_spin22):
    """
    Returns the appropriate NmtWorkspace object for the two supplied spins.

    Args:
        spin_a (int): Spin of one field.
        spin_2 (int): Spin of the other field.
        workspace_spin00 (NmtWorkspace): Workspace for two spin-0 fields.
        workspace_spin02 (NmtWorkspace): Workspace for one spin-0 and one spin-2 field (in either order).
        workspace_spin22 (NmtWorkspace): Workspace for two spin-2 fields.

    Returns:
        NmtWorkspace: The workspace object corresponding to the two supplied spins.
    """

    spins = (spin_a, spin_b)
    if spins == (0, 0):
        return workspace_spin00
    if spins in [(0, 2), (2, 0)]:
        return workspace_spin02
    if spins == (2, 2):
        return workspace_spin22
    raise ValueError(f'Unexpected combination of spins {spins}')