def optimizer(identifier, wrt, *args, **kwargs):
    """Return an optimizer with the desired configuration.

    This is a convenience function if one wants to try out different optimizers
    but wants to change as little code as possible.

    Additional arguments and keyword arguments will be passed to the constructor
    of the class. If the found class does not take the arguments supplied, this
    will `not` throw an error, but pass silently.

    :param identifier: String identifying the optimizer to use. Can be either
        ``asgd``, ``gd``, ``lbfgs``, ``ncg``, ``rprop``, ``adadelta`` or
        ``smd``.
    :param wrt: Numpy array pointing to the data to optimize.
    """
    klass_map = {
        'gd': GradientDescent,
        'lbfgs': Lbfgs,
        'ncg': NonlinearConjugateGradient,
        'rprop': Rprop,
        'rmsprop': RmsProp,
        'adadelta': Adadelta,
        'adam': Adam,
    }
    # Find out which arguments to pass on.
    klass = klass_map[identifier]
    argspec = inspect.getargspec(klass.__init__)
    if argspec.keywords is None:
        # Issue a warning for each of the arguments that have been passed
        # to this optimizer but were not used.
        expected_keys = set(argspec.args)
        given_keys = set(kwargs.keys())
        unused_keys = given_keys - expected_keys
        for i in unused_keys:
            warnings.warn('Argument named %s is not expected by %s'
                          % (i, klass))

        # We need to filter stuff out.
        used_keys = expected_keys & given_keys
        kwargs = dict((k, kwargs[k]) for k in used_keys)
    try:
        opt = klass(wrt, *args, **kwargs)
    except TypeError:
        raise TypeError((klass, argspec.args) % 'required arguments for %s: %s')

    return opt
dataset/ETHPy150Open BRML/climin/climin/util.py/optimizer/swapped operands of `%`