Backport of 9c19aff7c7561e3a82978a272ecdaad40dda5c00 from main.
We want to be able to use it for instance for discovering `tasks.py` modules inside the INSTALLED_APPS. This commit therefore moves the logic to `autodiscover_modules` method in django.utils.module_loading.