import pickle


def unpickle(file):
    """ Unpickle a file extracted from the cifar-10-python.tar.gz or cifar-100-python.tar.gz
        files.

    Args:
        file: path to binary file.

    Returns:
        decoded dict containing data.
    """

    with open(file, 'rb') as fo:
        dict_raw = pickle.load(fo, encoding='bytes')
        keys = list(dict_raw.keys())
        dict_decoded = {}
        for key in keys:
            dict_decoded[key.decode('utf-8')] = dict_raw[key]

    return dict_decoded