def download_nouns_mapping():
    """Downloads a mapping between noun id (``nXXXXXXXX`` form) and the noun string representation.

    :return: A dictionary: ``{noun_id : text}``
    """
    NOUN_MAP_URL = 'https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json'
    request = urlopen(NOUN_MAP_URL)
    class_map_json = request.read()

    # raw_dict has the form of {id: [noun_id, text]}. We flatten it into {noun_id: text}
    raw_dict = json.loads(class_map_json.decode("utf-8"))
    nouns_map = {k: v for k, v in raw_dict.values()}
    return nouns_map
Downloads a mapping between noun id (``nXXXXXXXX`` form) and the noun string representation.

    :return: A dictionary: ``{noun_id : text}``
    
examples/imagenet/generate_petastorm_imagenet.py