def METHOD_NAME():
    original_publish = current_stats.publish
    event_batches = defaultdict(list)
    def _patched_publish(self, event_type, events):
        events[0].update(event_data)
        event_batches[event_type].append(events[0])
    current_stats.publish = MethodType(_patched_publish, current_stats)
    yield
    current_stats.publish = original_publish
    for event_type, events in event_batches.items():
        current_stats.publish(event_type, events)