code: def to_base64_encoded_json(obj) -> str:
      """Encode a Python object as a base64-endoded JSON string.
  
      When embedding JSON inline inside HTML, serialize it to a JSON string in
      Python and base64 encode that string to escape it so that it's safe to render
      inside HTML.  Then on the JS side, base64 decode it and parse it as JSON.
  
      Args:
        obj: any Python object serializable to JSON
  
      Returns:
        base64-encoded string of JSON
      """
      json_string = json.dumps(obj)
      return base64.b64encode(json_string.encode("utf-8")).decode(
          "utf-8"
      )
  
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 3 for calling a global function with example usage: to_base64_encoded_json(obj) and returns: base64