code: def make_animation(
      frames: Sequence[np.ndarray],
      frame_rate: float,
      figsize: Optional[Union[float, Tuple[int, int]]],
  ) -> anim.Animation:
      """Generates a matplotlib animation from a stack of frames."""
  
      # Set animation characteristics.
      if figsize is None:
          height, width, _ = frames[0].shape
      elif isinstance(figsize, tuple):
          height, width = figsize
      else:
          diagonal = figsize
          height, width, _ = frames[0].shape
          scale_factor = diagonal / np.sqrt(height**2 + width**2)
          width *= scale_factor
          height *= scale_factor
  
      dpi = 70
      interval = int(
          round(1e3 / frame_rate)
      )  # Time (in ms) between frames.
  
      # Create and configure the figure.
      fig, ax = plt.subplots(
          1, 1, figsize=(width / dpi, height / dpi), dpi=dpi
      )
      ax.set_axis_off()
      ax.set_aspect("equal")
      ax.set_position([0, 0, 1, 1])
  
      # Initialize the first frame.
      im = ax.imshow(frames[0])
  
      # Create the function that will modify the frame, creating an animation.
      def update(frame):
          im.set_data(frame)
          return [im]
  
      return anim.FuncAnimation(
          fig=fig,
          func=update,
          frames=frames,
          interval=interval,
          blit=True,
          repeat=False,
      )
  
imports: import os.path
  import tempfile
  from typing import Callable, Optional, Sequence, Tuple, Union
  from acme.utils import paths
  from acme.wrappers import base
  import dm_env
  import matplotlib
  import matplotlib.animation
  import matplotlib.pyplot
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: make_animation(frames, frame_rate, figsize) and returns: anim, list