code: def _create_handler_wrapper(event_handlers):
      """Wraps the event handler and registers it as a callback for the js side.
  
      Wraps the event handler and registers it as a callback for js. Keep count and
      use it as aprt of the callback name to ensure uniqueness.
  
      Args:
        event_handlers: The hadnler for the js events.
  
      Returns:
        The name of the js callback, safe to render as HTML or JS.
      """
      trusted_name = "tfma_eventCallback" + str(
          int(_create_handler_wrapper.count)
      )
      _create_handler_wrapper.count += 1
  
      def wrapped_function(name="", detail=None):
          if event_handlers and name in event_handlers:
              event_handlers[name](detail)
  
      output.register_callback(trusted_name, wrapped_function)
      return trusted_name
  
file_path: model-analysis/tensorflow_model_analysis/notebook/colab/util.py
imports: import base64
  import json
  from typing import Any, Callable, Dict, List, Optional, Union
  from google.colab import output
  from IPython import display
label_desc: Use image node_id 1 for calling a global function with example usage: _create_handler_wrapper(event_handlers) and returns: trusted_name