@api.cache.memoize(timeout=120, fast=True)
def get_instance_number(pid, tid):
    """
    Maps the token to an instance number for a prolem.

    Args:
        pid: the problem id
        tid: the team id
    Returns:
        The instance number
    """

    previous_state = seed_generator(tid, pid)

    total_instances = get_number_of_instances(pid)
    if total_instances == 0:
        raise InternalException("{} has no instances.".format(pid))

    instance_number = random.randint(0, total_instances-1)
    random.setstate(previous_state)

    return instance_number
dataset/ETHPy150Open IceCTF/ctf-platform/api/api/autogen.py/get_instance_number/original