<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def apply_product_config(config):
 """Apply config values that are keyed by `cot_product`. This modifies the passed in configuration. Args: config dict: the config to apply cot_product keying too Returns: dict """

    cot_product = config['cot_product']

    for key in config:
        if isinstance(config[key], Mapping) and 'by-cot-product' in config[key]:
            try:
                config[key] = config[key]['by-cot-product'][cot_product]
            except KeyError:
                raise ConfigError("Product {} not specified for key {}".format(cot_product, key))

    return config