def install_registry(self, registry):
        """
        Install a *registry* (a templates.Registry instance) of function,
        attribute and global declarations.
        """
        try:
            loader = self._registries[registry]
        except KeyError:
            loader = templates.RegistryLoader(registry)
            self._registries[registry] = loader

        from numba.core.target_extension import (get_local_target,
                                                 resolve_target_str)
        current_target = get_local_target(self)

        def is_for_this_target(ftcls):
            metadata = getattr(ftcls, 'metadata', None)
            if metadata is None:
                return True

            target_str = metadata.get('target')
            if target_str is None:
                return True

            # There may be pending registrations for nonexistent targets.
            # Ideally it would be impossible to leave a registration pending
            # for an invalid target, but in practice this is exceedingly
            # difficult to guard against - many things are registered at import
            # time, and eagerly reporting an error when registering for invalid
            # targets would require that all target registration code is
            # executed prior to all typing registrations during the import
            # process; attempting to enforce this would impose constraints on
            # execution order during import that would be very difficult to
            # resolve and maintain in the presence of typical code maintenance.
            # Furthermore, these constraints would be imposed not only on
            # Numba internals, but also on its dependents.
            #
            # Instead of that enforcement, we simply catch any occurrences of
            # registrations for targets that don't exist, and report that
            # they're not for this target. They will then not be encountered
            # again during future typing context refreshes (because the
            # loader's new registrations are a stream_list that doesn't yield
            # previously-yielded items).
            try:
                ft_target = resolve_target_str(target_str)
            except errors.NonexistentTargetError:
                return False

            return current_target.inherits_from(ft_target)

        for ftcls in loader.new_registrations('functions'):
            if not is_for_this_target(ftcls):
                continue
            self.insert_function(ftcls(self))
        for ftcls in loader.new_registrations('attributes'):
            if not is_for_this_target(ftcls):
                continue
            self.insert_attributes(ftcls(self))
        for gv, gty in loader.new_registrations('globals'):
            existing = self._lookup_global(gv)
            if existing is None:
                self.insert_global(gv, gty)
            else:
                # A type was already inserted, see if we can add to it
                newty = existing.augment(gty)
                if newty is None:
                    raise TypeError("cannot augment %s with %s"
                                    % (existing, gty))
                self._remove_global(gv)
                self._insert_global(gv, newty)

        Install a *registry* (a templates.Registry instance) of function,
        attribute and global declarations.
        
numba/core/typing/context.py