code: def write_gif(dataset, filename, fps=10):
      
      try:
          check_dataset(dataset)
      except ValueError as e:
          dataset = try_fix_dataset(dataset)
          check_dataset(dataset)
      delay_time = 100 // int(fps)
  
      def encode(d):
          four_d = isinstance(dataset, numpy.ndarray) and len(dataset.shape) == 4
          if four_d or not isinstance(dataset, numpy.ndarray):
              return _make_animated_gif(d, delay_time=delay_time)
          else:
              return _make_gif(d)
  
      with open(filename, 'wb') as outfile:
          outfile.write(HEADER)
          for block in encode(dataset):
              outfile.write(block)
          outfile.write(TRAILER)
docs: Write a NumPy array to GIF 89a format.
  
      Or write a list of NumPy arrays to an animation (GIF 89a format).
  
      - Positional arguments::
  
          :param dataset: A NumPy arrayor list of arrays with shape
                          rgb x rows x cols and integer values in [0, 255].
          :param filename: The output file that will contain the GIF image.
          :param fps: The (integer) frames/second of the animation (default 10).
          :type dataset: a NumPy array or list of NumPy arrays.
          :return: None
  
      - Example: a minimal array, with one red pixel, would look like this::
  
          import numpy as np
          one_red_pixel = np.array([[[255]], [[0]], [[0]]])
          write_gif(one_red_pixel, 'red_pixel.gif')
  
      ..raises:: ValueError