def METHOD_NAME(fig):
    """Convert a figure to HTML."""
    if isinstance(fig, str):
        return fig
    elif isinstance(fig, matplotlib.pyplot.Figure):
        # https://stackoverflow.com/questions/48717794/matplotlib-embed-figures-in-auto-generated-html
        import base64
        from io import BytesIO
        temp_file = BytesIO()
        fig.savefig(temp_file, format="png")
        encoded = base64.b64encode(temp_file.getvalue()).decode("utf-8")
        return "<img src='data:image/png;base64,{}'>".format(encoded)
    else:
        try:
            import plotly
            if isinstance(fig, plotly.graph_objs._figure.Figure):
                # https://stackoverflow.com/questions/59868987/plotly-saving-multiple-plots-into-a-single-html
                return fig.to_html().split("<body>")[1].split("</body>")[0]
            else:
                return ""
        except ImportError:
            return ""