def load_candidate_from_stream(f):
    qid_to_ranked_candidate_passages = {}
    try:
        preds = json.load(f)
        for qid in preds.keys():
            tmp = ([0] * 50)
            qid_to_ranked_candidate_passages[qid] = tmp
            for (rank, pid) in enumerate(preds[qid][:50]):
                qid_to_ranked_candidate_passages[qid][rank] = pid
    except:
        raise IOError('Submitted file is not valid format')
    return qid_to_ranked_candidate_passages
def load_candidate_from_stream(f):
    qid_to_ranked_candidate_passages = {}
    try:
        preds = json.load(f)
        for qid in preds.keys():
            tmp = ([0] * 50)
            qid_to_ranked_candidate_passages[qid] = tmp
            for (rank, pid) in enumerate(preds[qid][:50]):
                qid_to_ranked_candidate_passages[qid][rank] = pid
    except:
        raise IOError('Submitted file is not valid format')
    return qid_to_ranked_candidate_passages