<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def app_templates_dirs(self):
 """ Build a cached dict with settings.INSTALLED_APPS as keys and the 'templates' directory of each application as values. """

        app_templates_dirs = OrderedDict()
        for app_config in apps.get_app_configs():
            templates_dir = os.path.join(
                getattr(app_config, 'path', '/'), 'templates')
            if os.path.isdir(templates_dir):
                templates_dir = upath(templates_dir)
                app_templates_dirs[app_config.name] = templates_dir
                app_templates_dirs[app_config.label] = templates_dir
        return app_templates_dirs