import math


def cosine(r_tokens: list, s_tokens: list) -> float:
    """Computes cosine similarity.

    COS(r, s) = |r ∩ s| / sqrt(|r| * |s|)

    Parameters
    ----------
    r_tokens : list
        First token list.
    s_tokens : list
        Second token list.

    Returns
    -------
    Cosine similarity of r and s.

    """

    return len(set(r_tokens).intersection(s_tokens)) / math.sqrt(len(r_tokens) * len(s_tokens))