code: def plot_and_save_video(
      geodesics,
      loss,
      size=20,
      fps=10,
      dpi=100,
      out="out.mp4",
      color="red",
  ):
      """Render a set of geodesics and save it to an mpeg 4 file."""
      fig = plt.figure(figsize=(size, size))
      ax = fig.add_subplot(111, projection="3d")
      sphere = visualization.Sphere()
      sphere.plot_heatmap(ax, loss)
      points = gs.to_ndarray(geodesics[0], to_ndim=2)
      sphere.add_points(points)
      sphere.draw(ax, color=color, marker=".")
  
      FFMpegWriter = animation.writers["ffmpeg"]
      writer = FFMpegWriter(fps=fps)
      with writer.saving(fig, out, dpi=dpi):
          for points in geodesics[1:]:
              points = gs.to_ndarray(points, to_ndim=2)
              sphere.draw_points(
                  ax, points=points, color=color, marker="."
              )
              writer.grab_frame()
  
file_path: geomstats/examples/gradient_descent_s2.py
imports: import logging
  import matplotlib
  import matplotlib.animation
  import matplotlib.pyplot
  import numpy
  import geomstats.backend
  import geomstats.visualization
  from geomstats.geometry.hypersphere import Hypersphere
  from geomstats.geometry.spd_matrices import SPDMatrices
label_desc: Use image node_id 2 for calling a global function with example usage: plot_and_save_video(geodesics, loss, size, fps, dpi, out, color) without return types