def clear_cached_models(self):
        """
        Clears the cache of generated models.
        """
        for model in self._cached_models.values():
            model.cleanup()

        self._cached_models.clear()
        gc.collect()

        Clears the cache of generated models.
        
coremltools/models/ml_program/experimental/debugging_utils.py