<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def config(self, averaging=1, datarate=15, mode=MODE_NORMAL):
 """ Set the base config for sensor :param averaging: Sets the numer of samples that are internally averaged :param datarate: Datarate in hertz :param mode: one of the MODE_* constants """

        averaging_conf = {
            1: 0,
            2: 1,
            4: 2,
            8: 3
        }

        if averaging not in averaging_conf.keys():
            raise Exception('Averaging should be one of: 1,2,4,8')
        datarates = {
            0.75: 0,
            1.5: 1,
            3: 2,
            7.5: 4,
            15: 5,
            30: 6,
            75: 7
        }
        if datarate not in datarates.keys():
            raise Exception(
                    'Datarate of {} Hz is not support choose one of: {}'.format(datarate, ', '.join(datarates.keys())))

        config_a = 0
        config_a &= averaging_conf[averaging] << 5
        config_a &= datarates[datarate] << 2
        config_a &= mode

        self.i2c_write_register(0x00, config_a)