def py_hash(key, num_buckets):
b, j = -<NUM_LIT:1>, <NUM_LIT:0><EOL>if num_buckets < <NUM_LIT:1>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>while j < num_buckets:<EOL><INDENT>b = int(j)<EOL>key = ((key * long(<NUM_LIT>)) + <NUM_LIT:1>) & <NUM_LIT><EOL>j = float(b + <NUM_LIT:1>) * (float(<NUM_LIT:1> << <NUM_LIT>) / float((key >> <NUM_LIT>) + <NUM_LIT:1>))<EOL><DEDENT>return int(b)<EOL>
Generate a number in the range [0, num_buckets).

    Args:
        key (int): The key to hash.
        num_buckets (int): Number of buckets to use.

    Returns:
        The bucket number `key` computes to.

    Raises:
        ValueError: If `num_buckets` is not a positive number.