<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def configure(self, *args, **kwargs):
 """Configure the Application through a varied number of sources of different types. This function chains multiple possible configuration methods together in order to just "make it work". You can pass multiple configuration sources in to the method and each one will be tried in a sane fashion. Later sources will override earlier sources if keys collide. For example: .. code:: python from application import default_config app.configure(default_config, os.environ, '.secrets') In the above example, values stored in ``default_config`` will be loaded first, then overwritten by those in ``os.environ``, and so on. An endless number of configuration sources may be passed. Configuration sources are type checked and processed according to the following rules: * ``string`` - if the source is a ``str``, we will assume it is a file or module that should be loaded. If the file ends in ``.json``, then :meth:`flask.Config.from_json` is used; if the file ends in ``.py`` or ``.cfg``, then :meth:`flask.Config.from_pyfile` is used; if the module has any other extension we assume it is an import path, import the module and pass that to :meth:`flask.Config.from_object`. See below for a few more semantics on module loading. * ``dict-like`` - if the source is ``dict-like``, then :meth:`flask.Config.from_mapping` will be used. ``dict-like`` is defined as anything implementing an ``items`` method that returns a tuple of ``key``, ``val``. * ``class`` or ``module`` - if the source is an uninstantiated ``class`` or ``module``, then :meth:`flask.Config.from_object` will be used. Just like Flask's standard configuration, only uppercased keys will be loaded into the config. If the item we are passed is a ``string`` and it is determined to be a possible Python module, then a leading ``.`` is relevant. If a leading ``.`` is provided, we assume that the module to import is located in the current package and operate as such; if it begins with anything else we assume the import path provided is absolute. This allows you to source configuration stored in a module in your package, or in another package. Args: *args (object):
 Any object you want us to try to configure from. Keyword Args: whitelist_keys_from_mappings (bool):
 Should we whitelist the keys we pull from mappings? Very useful if you're passing in an entire OS ``environ`` and you want to omit things like ``LESSPIPE``. If no whitelist is provided, we use the pre-existing config keys as a whitelist. whitelist (list[str]):
 An explicit list of keys that should be allowed. If provided and ``whitelist_keys`` is ``True``, we will use that as our whitelist instead of pre-existing app config keys. """

        whitelist_keys_from_mappings = kwargs.get(
            'whitelist_keys_from_mappings', False
        )
        whitelist = kwargs.get('whitelist')

        for item in args:
            if isinstance(item, string_types):
                _, ext = splitext(item)

                if ext == '.json':
                    self._configure_from_json(item)
                elif ext in ('.cfg', '.py'):
                    self._configure_from_pyfile(item)
                else:
                    self._configure_from_module(item)

            elif isinstance(item, (types.ModuleType, type)):
                self._configure_from_object(item)

            elif hasattr(item, 'items'):
                # assume everything else is a mapping like object; ``.items()``
                # is what Flask uses under the hood for this method
                # @TODO: This doesn't handle the edge case of using a tuple of
                # two element tuples to config; but Flask does that. IMO, if
                # you do that, you're a monster.
                self._configure_from_mapping(
                    item,
                    whitelist_keys=whitelist_keys_from_mappings,
                    whitelist=whitelist
                )

            else:
                raise TypeError("Could not determine a valid type for this"
                                " configuration object: `{}`!".format(item))

        # we just finished here, run the post configure callbacks
        self._run_post_configure_callbacks(args)