<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _set_i2c_speed(self, i2c_speed):
 """ Set I2C speed to one of '400kHz', '100kHz', 50kHz', '5kHz' """

        lower_bits_mapping = {
            '400kHz': 3,
            '100kHz': 2,
            '50kHz': 1,
            '5kHz': 0,
        }
        if i2c_speed not in lower_bits_mapping:
            raise ValueError('Invalid i2c_speed')
        speed_byte = 0b01100000 | lower_bits_mapping[i2c_speed]
        self.device.write(bytearray([speed_byte]))
        response = self.device.read(1)
        if response != b"\x01":
            raise Exception("Changing I2C speed failed. Received: {}".format(repr(response)))