<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def envelope(self, instrument):
 """ Computes isotopic envelope for a given instrument model :param instrument: instrument model to use :returns: isotopic envelope as a function of mass :rtype: function float(mz: float) """

        def envelopeFunc(mz):
            if isinstance(mz, numbers.Number):
                return ims.spectrum_envelope(self.ptr, instrument.ptr, mz)
            mzs = _cffi_buffer(mz, 'd')
            n = len(mz)
            buf = _cffi_buffer(n, 'f')
            ret = ims.spectrum_envelope_plot(self.ptr, instrument.ptr, mzs.ptr, n, buf.ptr)
            if ret < 0:
                _raise_ims_exception()
            return buf.python_data()

        return envelopeFunc