<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def admin_permission_factory(admin_view):
 """Default factory for creating a permission for an admin. It tries to load a :class:`invenio_access.permissions.Permission` instance if `invenio_access` is installed. Otherwise, it loads a :class:`flask_principal.Permission` instance. :param admin_view: Instance of administration view which is currently being protected. :returns: Permission instance. """

    try:
        pkg_resources.get_distribution('invenio-access')
        from invenio_access import Permission
    except pkg_resources.DistributionNotFound:
        from flask_principal import Permission

    return Permission(action_admin_access)