code: def generate_html_for_tfma_component(
      component_name: str,
      data: Union[
          List[Dict[str, Union[Dict[str, Any], str]]],
          Dict[str, List[Union[str, float, List[float]]]],
      ],
      config: Dict[str, Union[Dict[str, Dict[str, str]], str, bool]],
      trusted_html_for_vulcanized_tfma_js: str,
      event_handlers: Optional[PythonEventHandlersMap] = None,
  ) -> str:
      """Generates HTML for TFMA component.
  
      Args:
        component_name: The name of the TFMA web component to render.
        data: A dictionary containing data for visualization.
        config: A dictionary containing the configuration.
        trusted_html_for_vulcanized_tfma_js: Optional string of trusted HTML that is
          rendered unescaped.  This can be a script tag referencing a trusted
          external JS file or a script tag with trusted JS inline.
        event_handlers: Handlers for events on the js side.
  
      Returns:
        HTML content of the rendered TFMA component.
      """
  
      if component_name not in _TRUSTED_TFMA_COMPONENT_NAMES:
          raise ValueError(
              "component_name must be one of: "
              + ",".join(_TRUSTED_TFMA_COMPONENT_NAMES)
          )
  
      ui_payload = {"config": config, "data": data}
      template = """
      {trusted_html_for_vulcanized_tfma_js}
      <{trusted_tfma_component_name} id="component"></{trusted_tfma_component_name}>
      <script>
      const element = document.getElementById('component');
  
      {trusted_event_handler_js}
  
      const json = JSON.parse(atob('{base64_encoded_json_payload}'));
      element.config = json.config;
      element.data = json.data;
      </script>
      """
      html = template.format(
          trusted_tfma_component_name=component_name,
          trusted_html_for_vulcanized_tfma_js=trusted_html_for_vulcanized_tfma_js,
          trusted_event_handler_js=make_trusted_event_handler_js(
              event_handlers
          ),
          base64_encoded_json_payload=to_base64_encoded_json(
              ui_payload
          ),
      )
      return html
  
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 4 for calling a global function with example usage: generate_html_for_tfma_component(component_name, data, config, trusted_html_for_vulcanized_tfma_js, event_handlers) and returns: html