<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(screen_name=None, config_file=None, app=None, **kwargs):
 """ Set up a config dictionary using a bots.yaml config file and optional keyword args. Args: screen_name (str):
 screen_name of user to search for in config file config_file (str):
 Path to read for the config file app (str):
 Name of the app to look for in the config file. Defaults to the one set in users.{screen_name}. default_directories (str):
 Directories to read for the bots.yaml/json file. Defaults to CONFIG_DIRS. default_bases (str):
 File names to look for in the directories. Defaults to CONFIG_BASES. """

    # Use passed config file, or look for it in the default path.
    # Super-optionally, accept a different place to look for the file
    dirs = kwargs.pop('default_directories', None)
    bases = kwargs.pop('default_bases', None)
    file_config = {}
    if config_file is not False:
        config_file = find_file(config_file, dirs, bases)
        file_config = parse(config_file)

    # config and keys dicts
    # Pull non-authentication settings from the file.
    # Kwargs, user, app, and general settings are included, in that order of preference
    # Exclude apps and users sections from config
    config = {k: v for k, v in file_config.items() if k not in ('apps', 'users')}

    user_conf = file_config.get('users', {}).get(screen_name, {})
    app = app or user_conf.get('app')
    app_conf = file_config.get('apps', {}).get(app, {})

    # Pull user and app data from the file
    config.update(app_conf)
    config.update(user_conf)

    # kwargs take precendence over config file
    config.update({k: v for k, v in kwargs.items() if v is not None})

    return config