def load_obj(load_path):
    """
    Loads a saved on-disk representation to a python data structure. We
    currently support the following file formats:

        * python pickle (.pkl)

    Arguments:
        load_path (str): where to the load the serialized object (full path
                            and file name)

    """
    if isinstance(load_path, str):
        load_path = os.path.expandvars(os.path.expanduser(load_path))
        if load_path.endswith('.gz'):
            import gzip
            load_path = gzip.open(load_path)
        else:
            load_path = open(load_path)
    fname = load_path.name

    logger.debug("deserializing object from:  %s", fname)
    try:
        return pickle.load(load_path)
    except __HOLE__:
        msg = ("Problems deserializing: %s.  Its possible the interface "
               "for this object has changed since being serialized.  You "
               "may need to remove and recreate it." % load_path)
        logger.error(msg)
        raise AttributeError(msg)
dataset/ETHPy150Open NervanaSystems/neon/neon/util/persist.py/load_obj