def decode_classnumber(preds, top=5):
    """
    Return class number between 0 and 999 for each class amongst top=5 for each prediction in preds
    
    e.g.
    [[101, 386, 385, 149, 343]]
    """

    if len(preds.shape) != 2 or preds.shape[1] != 1000:
        raise ValueError('`decode_classnumber` expects '
                         'a batch of predictions '
                         '(i.e. a 2D array of shape (samples, 1000)). '
                         'Found array with shape: ' + str(preds.shape))
    results = []
    for pred in preds:
        top_indices = pred.argsort()[-top:][::-1]
        result = list(top_indices)
        results.append(result)
    return results