

def get_summary(stype, tag, value=None, collection_key=None, break_if_exists=False):
    " get_summary.\n\n    Create or retrieve a summary. It keep tracks of all graph summaries\n    through summary_tags collection. If a summary tags already exists,\n    it will return that summary tensor or raise an error (according to\n    'break_if_exists').\n\n    Arguments:\n        stype: `str`. Summary type: 'histogram', 'scalar' or 'image'.\n        tag: `str`. The summary tag (name).\n        value: `Tensor`. The summary initialization value. Default: None.\n        collection_key: `str`. If specified, the created summary will be\n            added to that collection (optional).\n        break_if_exists: `bool`. If True, if a summary with same tag already\n            exists, it will raise an exception (instead of returning that\n            existing summary).\n\n    Returns:\n        The summary `Tensor`.\n\n    "
    summ = next((item for item in tf.get_collection('summary_tags') if (item['tag'] == tag)), None)
    if (not summ):
        if (value is None):
            raise Exception("Summary doesn't exist, a value must be specified to initialize it.")
        if (stype == 'histogram'):
            summ = tf.histogram_summary(tag, value)
        elif (stype == 'scalar'):
            summ = tf.scalar_summary(tag, value)
        elif (stype == 'image'):
            pass
        else:
            raise ValueError((("Unknow summary type: '" + str(stype)) + "'"))
        tf.add_to_collection('summary_tags', {
            'tag': tag,
            'tensor': summ,
        })
        if collection_key:
            tf.add_to_collection(collection_key, summ)
    elif break_if_exists:
        raise ValueError("Error: Summary tag already exists! (to ignore this error, set add_summary() parameter 'break_if_exists' to False)")
    else:
        summ = summ['tensor']
    return summ

dataset/ETHPy150Open tflearn/tflearn/tflearn/summaries.py get_summary/original