<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def list_devices(class_name, name_pattern, **kwargs):
 """ This is a generator function that takes same arguments as `Device` class and enumerates all devices present in the system that match the provided arguments. Parameters: class_name: class name of the device, a subdirectory of /sys/class. For example, 'tacho-motor'. name_pattern: pattern that device name should match. For example, 'sensor*' or 'motor*'. Default value: '*'. keyword arguments: used for matching the corresponding device attributes. For example, address='outA', or driver_name=['lego-ev3-us', 'lego-nxt-us']. When argument value is a list, then a match against any entry of the list is enough. """

    classpath = abspath(Device.DEVICE_ROOT_PATH + '/' + class_name)

    return (Device(class_name, name, name_exact=True)
            for name in list_device_names(classpath, name_pattern, **kwargs))