code: def gif_summary(name, tensor, max_outputs=3, fps=10, collections=None,
                  family=None):
    
    tensor = tf.convert_to_tensor(tensor)
    if len(tensor.get_shape()) != 5:
      raise ValueError("Assuming videos given as tensors in the format "
                       "[batch, time, height, width, channels] but got one "
                       "of shape: %s" % str(tensor.get_shape()))
    tensor = tf.cast(tensor, tf.uint8)
    if distribute_summary_op_util.skip_summary():
      return tf.constant("")
    with summary_op_util.summary_scope(
        name, family, values=[tensor]) as (tag, scope):
      val = tf.py_func(
          py_gif_summary,
          [tag, tensor, max_outputs, fps],
          tf.string,
          stateful=False,
          name=scope)
      summary_op_util.collect(val, collections, [tf.GraphKeys.SUMMARIES])
    return val
docs: Outputs a `Summary` protocol buffer with gif animations.
  
    Args:
      name: Name of the summary.
      tensor: A 5-D `uint8` `Tensor` of shape `[batch_size, time, height, width,
        channels]` where `channels` is 1 or 3.
      max_outputs: Max number of batch elements to generate gifs for.
      fps: frames per second of the animation
      collections: Optional list of tf.GraphKeys.  The collections to add the
        summary to.  Defaults to [tf.GraphKeys.SUMMARIES]
      family: Optional; if provided, used as the prefix of the summary tag name,
        which controls the tab name used for display on Tensorboard.
  
    Returns:
      A scalar `Tensor` of type `string`. The serialized `Summary` protocol
      buffer.
  
    Raises:
      ValueError: if the given tensor has the wrong shape.