Given a list of metric events sorted by non-decreasing timestamp and an integer window_size, return the alerts that should be emitted after deduplicating duplicates within the last window_size seconds. Each event is a dictionary with timestamp, metric, severity, and value. Two events are duplicates if they have the same metric and severity, and their timestamps differ by at most window_size. Keep the first event and suppress later duplicates inside the active window.
def deduplicate_alerts(events, window_size):