code: def make_trusted_event_handler_js(event_handlers):
      """Generates event handler code in js if provided.
  
      If python event_handlers are provided, generate corresponding js callback and
      trigger it when applicable.  See tfma-nb-event-mixin.js
  
      Args:
       event_handlers: The hadnler for the hs events.
  
      Returns:
        Trusted js code that will call the event handler in python.
      """
      if event_handlers:
          trusted_callback_name = _create_handler_wrapper(
              event_handlers
          )
          return """
            element.addEventListener('tfma-event', (event) => {{
              google.colab.kernel.invokeFunction(
                  '{trusted_callback_name}', [], {{
                  name: event.detail.type,
                  detail: event.detail.detail
              }});
            }});
       """.format(
              trusted_callback_name=trusted_callback_name
          )
      else:
          return "/** No event handlers needed. */"
  
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 2 for calling a global function with example usage: make_trusted_event_handler_js(event_handlers) and returns: str, str