<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def animate_police_lights(self, color1, color2, group1='LEFT', group2='RIGHT', sleeptime=0.5, duration=5, block=True):
 """ Cycle the ``group1`` and ``group2`` LEDs between ``color1`` and ``color2`` to give the effect of police lights. Alternate the ``group1`` and ``group2`` LEDs every ``sleeptime`` seconds. Animate for ``duration`` seconds. If ``duration`` is None animate for forever. Example: .. code-block:: python from ev3dev2.led import Leds leds = Leds() leds.animate_police_lights('RED', 'GREEN', sleeptime=0.75, duration=10) """


        def _animate_police_lights():
            self.all_off()
            even = True
            start_time = dt.datetime.now()

            while True:
                if even:
                    self.set_color(group1, color1)
                    self.set_color(group2, color2)
                else:
                    self.set_color(group1, color2)
                    self.set_color(group2, color1)

                if self.animate_thread_stop or duration_expired(start_time, duration):
                    break

                even = not even
                sleep(sleeptime)

            self.animate_thread_stop = False
            self.animate_thread_id = None

        self.animate_stop()

        if block:
            _animate_police_lights()
        else:
            self.animate_thread_id = _thread.start_new_thread(_animate_police_lights, ())