<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def send_figure(self, fig, caption=''):
 """Render matplotlib figure into temporary bytes buffer and then send it to telegram user. :param fig: matplotlib figure object. :param caption: text caption of picture. :return: status code on error. """

        if not self.is_token_set:
            raise ValueError('TelepythClient: Access token is not set!')

        figure = BytesIO()
        fig.savefig(figure, format='png')
        figure.seek(0)

        parts = [ContentDisposition('caption', caption),
                 ContentDisposition('figure', figure, filename="figure.png",
                                    content_type='image/png')]

        form = MultipartFormData(*parts)
        content_type = 'multipart/form-data; boundary=%s' % form.boundary

        url = self.base_url + self.access_token
        req = Request(url, method='POST')
        req.add_header('Content-Type', content_type)
        req.add_header('User-Agent', __user_agent__ + '/' + __version__)
        req.data = form().read()

        res = urlopen(req)

        return res.getcode()