<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_morphology(self, name, **kwargs):
 """Set the spatial model of a source. Parameters name : str Source name. spatial_model : str Spatial model name (PointSource, RadialGaussian, etc.). spatial_pars : dict Dictionary of spatial parameters (optional). use_cache : bool Generate the spatial model by interpolating the cached source map. use_pylike : bool """


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

        spatial_model = kwargs.get('spatial_model', src['SpatialModel'])
        spatial_pars = kwargs.get('spatial_pars', {})
        use_pylike = kwargs.get('use_pylike', True)
        psf_scale_fn = kwargs.get('psf_scale_fn', None)
        update_source = kwargs.get('update_source', False)

        if hasattr(pyLike.BinnedLikelihood, 'setSourceMapImage') and not use_pylike:
            src.set_spatial_model(spatial_model, spatial_pars)
            self._update_srcmap(src.name, src, psf_scale_fn=psf_scale_fn)
        else:
            src = self.delete_source(name, loglevel=logging.DEBUG,
                                     save_template=False)
            src.set_spatial_model(spatial_model, spatial_pars)
            self.add_source(src.name, src, init_source=False,
                            use_pylike=use_pylike, loglevel=logging.DEBUG)

        if update_source:
            self.update_source(name)