<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_source_spectrum(self, name, spectrum_type='PowerLaw', spectrum_pars=None, update_source=True):
 """Set the spectral model of a source. This function can be used to change the spectral type of a source or modify its spectral parameters. If called with spectrum_type='FileFunction' and spectrum_pars=None, the source spectrum will be replaced with a FileFunction with the same differential flux distribution as the original spectrum. Parameters name : str Source name. spectrum_type : str Spectrum type (PowerLaw, etc.). spectrum_pars : dict Dictionary of spectral parameters (optional). update_source : bool Recompute all source characteristics (flux, TS, NPred) using the new spectral model of the source. """

        name = self.roi.get_source_by_name(name).name
        src = self.roi[name]

        spectrum_pars = {} if spectrum_pars is None else spectrum_pars
        if (self.roi[name]['SpectrumType'] == 'PowerLaw' and
                spectrum_type == 'LogParabola'):
            spectrum_pars.setdefault('beta', {'value': 0.0, 'scale': 1.0,
                                              'min': 0.0, 'max': 1.0})
            spectrum_pars.setdefault('Eb', src.spectral_pars['Scale'])
            spectrum_pars.setdefault('norm', src.spectral_pars['Prefactor'])
            if 'alpha' not in spectrum_pars:
                spectrum_pars['alpha'] = src.spectral_pars['Index']
                spectrum_pars['alpha']['value'] *= -1.0
                if spectrum_pars['alpha']['scale'] == -1.0:
                    spectrum_pars['alpha']['value'] *= -1.0
                    spectrum_pars['alpha']['scale'] *= -1.0

        if spectrum_type == 'FileFunction':
            self._create_filefunction(name, spectrum_pars)
        else:
            fn = gtutils.create_spectrum_from_dict(spectrum_type,
                                                   spectrum_pars)
            self.like.setSpectrum(str(name), fn)

        # Get parameters
        src = self.components[0].like.logLike.getSource(str(name))
        pars_dict = gtutils.get_function_pars_dict(src.spectrum())

        self.roi[name]['SpectrumType'] = spectrum_type
        self.roi[name].set_spectral_pars(pars_dict)
        for c in self.components:
            c.roi[name]['SpectrumType'] = spectrum_type
            c.roi[name].set_spectral_pars(pars_dict)

        if update_source:
            self.update_source(name)