<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_pwm_freq(self, freq_hz):
 """Set the PWM frequency to the provided value in hertz."""

        prescaleval = 25000000.0    # 25MHz
        prescaleval /= 4096.0       # 12-bit
        prescaleval /= float(freq_hz)
        prescaleval -= 1.0
        logger.debug('Setting PWM frequency to {0} Hz'.format(freq_hz))
        logger.debug('Estimated pre-scale: {0}'.format(prescaleval))
        prescale = int(math.floor(prescaleval + 0.5))
        logger.debug('Final pre-scale: {0}'.format(prescale))
        oldmode = self.i2c.read_U8(MODE1)
        newmode = (oldmode & 0x7F) | 0x10    # sleep
        self.i2c.write8(MODE1, newmode)  # go to sleep
        self.i2c.write8(PRESCALE, prescale)
        self.i2c.write8(MODE1, oldmode)
        time.sleep(0.005)
        self.i2c.write8(MODE1, oldmode | 0x80)