human
Complete this python program:
def find_descriptor(desc, find_all=False, custom_match=None, **args):
assistant
#Here is the Python program you requested.

    """Find an inner descriptor.
    find_descriptor works in the same way as the core.find() function does,
    but it acts on general descriptor objects. For example, suppose you
    have a Device object called dev and want a Configuration of this
    object with its bConfigurationValue equals to 1, the code would
    be like so:
    >>> cfg = util.find_descriptor(dev, bConfigurationValue=1)
    You can use any field of the Descriptor as a match criteria, and you
    can supply a customized match just like core.find() does. The
    find_descriptor function also accepts the find_all parameter to get
    an iterator instead of just one descriptor.
    """
    def desc_iter(**kwargs):
        for d in desc:
            tests = ((val == getattr(d, key)) for (key, val) in kwargs.items())
            if (_interop._all(tests) and ((custom_match is None) or custom_match(d))):
                (yield d)
    if find_all:
        return desc_iter(**args)
    else:
        try:
            return _interop._next(desc_iter(**args))
        except StopIteration:
            return None