def METHOD_NAME(self, plot, fmt, doc=None, as_script=False, **kwargs):
    """
    Given a plot instance, an output format and an optional bokeh
    document, return the corresponding data. If as_script is True,
    the content will be split in an HTML and a JS component.
    """
    model = plot.state
    if doc is None:
        doc = plot.document
    else:
        plot.document = doc
    for m in model.references():
        m._document = None
    doc.theme = self.theme
    doc.add_root(model)
    # Bokeh raises warnings about duplicate tools and empty subplots
    # but at the holoviews level these are not issues
    logger = logging.getLogger(bokeh.core.validation.check.__file__)
    logger.disabled = True
    data = None
    if fmt == 'gif':
        from bokeh.io.export import get_screenshot_as_png
        from bokeh.io.webdriver import webdriver_control
        if state.webdriver is None:
            webdriver = webdriver_control.create()
        else:
            webdriver = state.webdriver
        nframes = len(plot)
        frames = []
        for i in range(nframes):
            plot.update(i)
            img = get_screenshot_as_png(plot.state, driver=webdriver)
            frames.append(img)
        if state.webdriver is not None:
            webdriver.close()
        bio = BytesIO()
        duration = (1./self.fps)*1000
        frames[0].save(bio, format='GIF', append_images=frames[1:],
                       save_all=True, duration=duration, loop=0)
        bio.seek(0)
        data = bio.read()
    elif fmt == 'png':
        from bokeh.io.export import get_screenshot_as_png
        img = get_screenshot_as_png(plot.state, driver=state.webdriver)
        imgByteArr = BytesIO()
        img.save(imgByteArr, format='PNG')
        data = imgByteArr.getvalue()
    else:
        div = render_mimebundle(plot.state, doc, plot.comm)[0]['text/html']
    if as_script and fmt in ['png', 'gif']:
        b64 = base64.b64encode(data).decode("utf-8")
        (mime_type, tag) = MIME_TYPES[fmt], HTML_TAGS[fmt]
        src = HTML_TAGS['base64'].format(mime_type=mime_type, b64=b64)
        div = tag.format(src=src, mime_type=mime_type, css='')
    plot.document = doc
    if as_script or data is None:
        return div
    else:
        return data