code: def test_record_event(self):
      events = []
      counters = {}  # Map event names to frequency.
  
      def increment_event_counter(event):
          if event not in counters:
              counters[event] = 0
          counters[event] += 1
  
      # Test that we can register multiple callbacks.
      monitoring.register_event_listener(events.append)
      monitoring.register_event_listener(increment_event_counter)
  
      monitoring.record_event("test_unique_event")
      monitoring.record_event("test_common_event")
      monitoring.record_event("test_common_event")
  
      self.assertListEqual(
          events,
          [
              "test_unique_event",
              "test_common_event",
              "test_common_event",
          ],
      )
      self.assertDictEqual(
          counters, {"test_unique_event": 1, "test_common_event": 2}
      )
  
file_path: jax/tests/monitoring_test.py
imports: from absl.testing import absltest
  from jax import monitoring
  from jax._src import monitoring
label_desc: Use image node_id 2 for calling the MonitoringTest obj's underlying member method code with example usage: obj.test_record_event() without return types