<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def trigger(self, when=1):
 """Declare a window with this window's size and a trigger policy. When the window is triggered is defined by `when`. If `when` is an `int` then the window is triggered every `when` tuples. For example, with ``when=5`` the window will be triggered every five tuples. If `when` is an `datetime.timedelta` then it is the period of the trigger. With a `timedelta` representing one minute then the window is triggered every minute. By default, when `trigger` has not been called on a `Window` it triggers for every tuple inserted into the window (equivalent to ``when=1``). Args: when: The size of the window, either an `int` to define the number of tuples or `datetime.timedelta` to define the duration of the window. Returns: Window: Window that will be triggered. .. warning:: A trigger is only supported for a sliding window such as one created by :py:meth:`last`. """

        tw = Window(self.stream, self._config['type'])
        tw._config['evictPolicy'] = self._config['evictPolicy']
        tw._config['evictConfig'] = self._config['evictConfig']
        if self._config['evictPolicy'] == 'TIME':
            tw._config['evictTimeUnit'] = 'MILLISECONDS'

        if isinstance(when, datetime.timedelta):
            tw._config['triggerPolicy'] = 'TIME'
            tw._config['triggerConfig'] = int(when.total_seconds() * 1000.0)
            tw._config['triggerTimeUnit'] = 'MILLISECONDS'
        elif isinstance(when, int):
            tw._config['triggerPolicy'] = 'COUNT'
            tw._config['triggerConfig'] = when
        else:
            raise ValueError(when)
        return tw