def METHOD_NAME(config: Dict[str, Any], state: State):
    precision = state.precision
    # Verify DeepSpeed config is consistent with state.precision if set. DeepSpeed precision config
    # has many different ways to specify approximately the same thing. See https://www.deepspeed.ai/docs/config-json/.
    ds_precision = None
    if 'fp16' in config and 'enabled' in config['fp16'] and config['fp16']['enabled']:
        ds_precision = Precision.AMP_FP16
    elif 'bf16' in config and 'enabled' in config['bf16'] and config['bf16']['enabled']:
        ds_precision = Precision.AMP_BF16
    elif 'amp' in config and 'enabled' in config['amp'] and config['amp']['enabled']:
        ds_precision = Precision.AMP_FP16
    if ds_precision is not None and ds_precision != precision:
        raise ValueError((f'Provided DeepSpeed configuration specifies precision={ds_precision}, '
                          f'but the Mosaic trainer has been configured with precision={precision}.'))
    # Set DeepSpeed config based on state.precision if not set
    if precision == Precision.AMP_FP16 and 'fp16' not in config:
        config['fp16'] = cast(Dict[str, Any], {'enabled': True})
    elif precision == Precision.AMP_BF16 and 'bf16' not in config:
        config['bf16'] = cast(Dict[str, Any], {'enabled': True})