class_docstr: Format a video for logging to W&B.
  
  Arguments:
      data_or_path: (numpy array, string, io)
          Video can be initialized with a path to a file or an io object.
          The format must be "gif", "mp4", "webm" or "ogg".
          The format must be specified with the format argument.
          Video can be initialized with a numpy tensor.
          The numpy tensor must be either 4 dimensional or 5 dimensional.
          Channels should be (time, channel, height, width) or
          (batch, time, channel, height width)
      caption: (string) caption associated with the video for display
      fps: (int) frames per second for video. Default is 4.
      format: (string) format of video, necessary if initializing with path or io object.
  
  Examples:
      ### Log a numpy array as a video
      <!--yeadoc-test:log-video-numpy-->
      ```python
      import numpy as np
      import wandb
  
      wandb.init()
      # axes are (time, channel, height, width)
      frames = np.random.randint(low=0, high=256, size=(10, 3, 100, 100), dtype=np.uint8)
      wandb.log({"video": wandb.Video(frames, fps=4)})
      ```
class_docstr_tok: ["Format","a","video","for","logging","to","W","&","B",".","Arguments",":","data_or_path",":","(","numpy","array",",","string",",","io",")","Video","can","be","initialized","with","a","path","to","a","file","or","an","io","object",".","The","format","must","be","``","gif","''",",","``","mp4","''",",","``","webm","''","or","``","ogg","''",".","The","format","must","be","specified","with","the","format","argument",".","Video","can","be","initialized","with","a","numpy","tensor",".","The","numpy","tensor","must","be","either","4","dimensional","or","5","dimensional",".","Channels","should","be","(","time",",","channel",",","height",",","width",")","or","(","batch",",","time",",","channel",",","height","width",")","caption",":","(","string",")","caption","associated","with","the","video","for","display","fps",":","(","int",")","frames","per","second","for","video",".","Default","is","4.","format",":","(","string",")","format","of","video",",","necessary","if","initializing","with","path","or","io","object",".","Examples",":","#","#","#","Log","a","numpy","array","as","a","video","<","!","--","yeadoc-test",":","log-video-numpy","--",">","``","`","python","import","numpy","as","np","import","wandb","wandb.init","(",")","#","axes","are","(","time",",","channel",",","height",",","width",")","frames","=","np.random.randint","(","low=0",",","high=256",",","size=","(","10",",","3",",","100",",","100",")",",","dtype=np.uint8",")","wandb.log","(","{","``","video","''",":","wandb.Video","(","frames",",","fps=4",")","}",")","``","`"]
docstr: This logic was mostly taken from tensorboardX.
docstr_tok: ["This","logic","was","mostly","taken","from","tensorboardX","."]
code: def _prepare_video(self, video: "np.ndarray") -> "np.ndarray":
      """This logic was mostly taken from tensorboardX."""
      np = util.get_module(
          "numpy",
          required='wandb.Video requires numpy when passing raw data. To get it, run "pip install numpy".',
      )
      if video.ndim < 4:
          raise ValueError(
              "Video must be atleast 4 dimensions: time, channels, height, width"
          )
      if video.ndim == 4:
          video = video.reshape(1, *video.shape)
      b, t, c, h, w = video.shape
  
      if video.dtype != np.uint8:
          logging.warning("Converting video data to uint8")
          video = video.astype(np.uint8)
  
      def is_power2(num: int) -> bool:
          return num != 0 and ((num & (num - 1)) == 0)
  
      # pad to nearest power of 2, all at once
      if not is_power2(video.shape[0]):
          len_addition = int(
              2 ** video.shape[0].bit_length() - video.shape[0]
          )
          video = np.concatenate(
              (video, np.zeros(shape=(len_addition, t, c, h, w))),
              axis=0,
          )
  
      n_rows = 2 ** ((b.bit_length() - 1) // 2)
      n_cols = video.shape[0] // n_rows
  
      video = np.reshape(video, newshape=(n_rows, n_cols, t, c, h, w))
      video = np.transpose(video, axes=(2, 0, 4, 1, 5, 3))
      video = np.reshape(video, newshape=(t, n_rows * h, n_cols * w, c))
      return video
  
file_path: wandb/wandb/sdk/data_types/video.py
imports: import logging
  import os
  from io import BytesIO
  from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence, Type, Union
  from wandb import util
  from wandb.sdk.lib import filesystem, runid
  from .None import _dtypes
  from ._private import MEDIA_TMP
  from .base_types.media import BatchableMedia
label_desc: Use image node_id 5 for calling the Video obj's underlying member method code with example usage: obj._prepare_video(video) and returns: video, unknown