code: def anim_to_html(anim, fps=None, embed_frames=True, default_mode='loop'):
      
      if fps is None and hasattr(anim, '_interval'):
          # Convert interval in ms to frames per second
          fps = 1000. / anim._interval
  
      plt.close(anim._fig)
      if hasattr(anim, "_html_representation"):
          return anim._html_representation
      else:
          # tempfile can't be used here: we need a filename, and this
          # fails on windows.  Instead, we use a custom filename generator
          #with tempfile.NamedTemporaryFile(suffix='.html') as f:
          with _NameOnlyTemporaryFile(suffix='.html') as f:
              anim.save(f.name,  writer=HTMLWriter(fps=fps,
                                                   embed_frames=embed_frames,
                                                   default_mode=default_mode))
              html = open(f.name).read()
  
          anim._html_representation = html
          return html
docs: Generate HTML representation of the animation