<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load_extensions(self, group, name_filter=None, comp_filter=None, class_filter=None, product_name=None, unique=False):
 """Dynamically load and return extension objects of a given type. This is the centralized way for all parts of CoreTools to allow plugin behavior. Whenever a plugin is needed, this method should be called to load it. Examples of plugins are proxy modules, emulated tiles, iotile-build autobuilders, etc. Each kind of plugin will typically be a subclass of a certain base class and can be provided one of three ways: 1. It can be registered as an entry point in a pip installed package. The entry point group must map the group passed to load_extensions. 2. It can be listed as a product of an IOTile component that is stored in this ComponentRegistry. The relevant python file inside the component will be imported dynamically as needed. 3. It can be programmatically registered by calling ``register_extension()`` on this class with a string name and an object. This is equivalent to exposing that same object as an entry point with the given name. There is special behavior of this function if class_filter is passed and the object returned by one of the above three methods is a python module. The module will be search for object definitions that match the defined class. The order of the returned objects list is only partially defined. Locally installed components are searched before pip installed packages with entry points. The order of results within each group is not specified. Args: group (str):
 The extension type that you wish to enumerate. This will be used as the entry_point group for searching pip installed packages. name_filter (str):
 Only return objects with the given name comp_filter (str):
 When searching through installed components (not entry_points), only search through components with the given name. class_filter (type or tuple of types):
 An object that will be passed to instanceof() to verify that all extension objects have the correct types. If not passed, no checking will be done. product_name (str):
 If this extension can be provided by a registered local component, the name of the product that should be loaded. unique (bool):
 If True (default is False), there must be exactly one object found inside this extension that matches all of the other criteria. Returns: list of (str, object):
 A list of the found and loaded extension objects. The string returned with each extension is the name of the entry_point or the base name of the file in the component or the value provided by the call to register_extension depending on how the extension was found. If unique is True, then the list only contains a single entry and that entry will be directly returned. """


        found_extensions = []

        if product_name is not None:
            for comp in self.iter_components():
                if comp_filter is not None and comp.name != comp_filter:
                    continue

                products = comp.find_products(product_name)
                for product in products:
                    try:
                        entries = self.load_extension(product, name_filter=name_filter, class_filter=class_filter,
                                                      component=comp)
                        if len(entries) == 0 and name_filter is None:
                            # Don't warn if we're filtering by name since most extensions won't match
                            self._logger.warn("Found no valid extensions in product %s of component %s",
                                              product, comp.path)
                            continue

                        found_extensions.extend(entries)
                    except:  # pylint:disable=bare-except;We don't want a broken extension to take down the whole system
                        self._logger.exception("Unable to load extension %s from local component %s at path %s",
                                               product_name, comp, product)

        for entry in self._iter_entrypoint_group(group):
            name = entry.name

            if name_filter is not None and name != name_filter:
                continue

            try:
                ext = entry.load()
            except:  # pylint:disable=bare-except;
                self._logger.warn("Unable to load %s from %s", entry.name, entry.distro, exc_info=True)
                continue

            found_extensions.extend((name, x) for x in self._filter_subclasses(ext, class_filter))

        for (name, ext) in self._registered_extensions.get(group, []):
            if name_filter is not None and name != name_filter:
                continue

            found_extensions.extend((name, x) for x in self._filter_subclasses(ext, class_filter))

        found_extensions = [(name, x) for name, x in found_extensions if self._filter_nonextensions(x)]

        if unique is True:
            if len(found_extensions) > 1:
                raise ArgumentError("Extension %s should have had exactly one instance of class %s, found %d" % (group, class_filter.__name__, len(found_extensions)), classes=found_extensions)
            elif len(found_extensions) == 0:
                raise ArgumentError("Extension %s had no instances of class %s" % (group, class_filter.__name__))

            return found_extensions[0]

        return found_extensions