def filtered_config_from_config(config):
    """
    Remove items from 'environments', 'n_episodes', 'n_steps', 'n_instances', 'timeout' lists in config.
    The removed items are those whose index matches a 0 in config['filter'].
    :param config: (dict) main configuration dict
    :return: (dict) the filtered main configuration dict
    """
    if 'filter' in config.keys() and config['filter'] is not None:
        f = config['filter']
        for key in ['environments', 'n_episodes', 'n_steps', 'n_instances', 'timeout']:
            if type(config[key]) is list:
                config[key] = [config[key][i] for i in range(len(f)) if f[i]]
    return config