code: def save_html_with_metadata(fig, filename, fig_kwds, kwds):
      
      if isinstance(fig, str):
          text = fig
      else:
          from mpld3 import fig_to_html
          text = fig_to_html(fig, **fig_kwds)
  
      f = open(filename, 'w')
      for key, value in kwds.items():
          value = escape(value, escape_table)
          line = "<div class=pycbc-meta key=\"%s\" value=\"%s\"></div>" % (str(key), value)
          f.write(line)
  
      f.write(text)
docs: Save a html output to file with metadata