<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_buffer_options(self, options, bufnr=None):
 """Set buffer-local options for a buffer, defaulting to current. Args: options (dict):
 Options to set, with keys being Vim option names. For Boolean options, use a :class:`bool` value as expected, e.g. ``{'buflisted': False}`` for ``setlocal nobuflisted``. bufnr (Optional[int]):
 A Vim buffer number, as you might get from VimL ``bufnr('%')`` or Python ``vim.current.buffer.number``. If ``None``, options are set on the current buffer. """

        buf = self._vim.buffers[bufnr] if bufnr else self._vim.current.buffer

        # Special case handling for filetype, see doc on ``set_filetype``
        filetype = options.pop('filetype', None)
        if filetype:
            self.set_filetype(filetype)

        for opt, value in options.items():
            buf.options[opt] = value