<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def hold(model: Model, reducer: Optional[Callable] = None) -> Iterator[list]: """Temporarilly withold change events in a modifiable list. All changes that are captured within a "hold" context are forwarded to a list which is yielded to the user before being sent to views of the given ``model``. If desired, the user may modify the list of events before the context is left in order to change the events that are ultimately sent to the model's views. Parameters: model: The model object whose change events will be temporarilly witheld. reducer: A function for modifying the events list at the end of the context. Its signature is ``(model, events) -> new_events`` where ``model`` is the given model, ``events`` is the complete list of events produced in the context, and the returned ``new_events`` is a list of events that will actuall be distributed to views. Notes: All changes witheld from views will be sent as a single notification. For example if you view a :class:`specate.mvc.models.List` and its ``append()`` method is called three times within a :func:`hold` context, Examples: Note how the event from ``l.append(1)`` is omitted from the printed statements. .. code-block:: python from spectate import mvc l = mvc.List() mvc.view(d, lambda d, e: list(map(print, e))) with mvc.hold(l) as events: l.append(1) l.append(2) del events[0] .. code-block:: text {'index': 1, 'old': Undefined, 'new': 2} """

    if not isinstance(model, Model):
        raise TypeError("Expected a Model, not %r." % model)
    events = []
    restore = model.__dict__.get("_notify_model_views")
    model._notify_model_views = lambda e: events.extend(e)

    try:
        yield events
    finally:
        if restore is None:
            del model._notify_model_views
        else:
            model._notify_model_views = restore

        events = tuple(events)

        if reducer is not None:
            events = tuple(map(Data, reducer(model, events)))

        model._notify_model_views(events)