import tempfile


def serialize(figure: tempfile._TemporaryFileWrapper) -> bytes:
    """
    Serialize a figure that has been rendered

    Parameters
    ----------
    figure
        figure
    """
    with open(figure.name, "rb") as f:
        return f.read()