class_docstr: A class for exporting videos.
docstr: Write a frame to the video.
  
  Args:
      frame: An object containing the frame image.
      resize: Either a floating defining the image rescaling factor
          or a 2-tuple defining the size of the output image.
docstr_tok: ["Write","a","frame","to","the","video",".","Args",":","frame",":","An","object","containing","the","frame","image",".","resize",":","Either","a","floating","defining","the","image","rescaling","factor","or","a","2-tuple","defining","the","size","of","the","output","image","."]
code: def write_frame(
      self,
      frame: Union[
          matplotlib.figure.Figure, np.ndarray, Image.Image, str
      ],
      resize: Optional[Union[float, Tuple[int, int]]] = None,
  ) -> None:
      """
      Write a frame to the video.
  
      Args:
          frame: An object containing the frame image.
          resize: Either a floating defining the image rescaling factor
              or a 2-tuple defining the size of the output image.
      """
  
      # pyre-fixme[6]: For 1st argument expected `Union[PathLike[str], str]` but
      #  got `Optional[str]`.
      outfile = os.path.join(
          self.cache_dir, self.regexp % self.frame_num
      )
  
      if isinstance(frame, matplotlib.figure.Figure):
          plt.savefig(outfile)
          im = Image.open(outfile)
      elif isinstance(frame, np.ndarray):
          if frame.dtype in (np.float64, np.float32, float):
              frame = (np.transpose(frame, (1, 2, 0)) * 255.0).astype(
                  np.uint8
              )
          im = Image.fromarray(frame)
      elif isinstance(frame, Image.Image):
          im = frame
      elif isinstance(frame, str):
          im = Image.open(frame).convert("RGB")
      else:
          raise ValueError("Cant convert type %s" % str(type(frame)))
  
      if im is not None:
          if resize is not None:
              if isinstance(resize, float):
                  resize = [int(resize * s) for s in im.size]
          else:
              resize = im.size
          # make sure size is divisible by 2
          resize = tuple([resize[i] + resize[i] % 2 for i in (0, 1)])
          # pyre-fixme[16]: Module `Image` has no attribute `ANTIALIAS`.
          im = im.resize(resize, Image.ANTIALIAS)
          im.save(outfile)
  
      self.frames.append(outfile)
      self.frame_num += 1
  
file_path: pytorch3d/pytorch3d/implicitron/tools/video_writer.py
imports: import os
  import shutil
  import subprocess
  import tempfile
  import warnings
  from typing import Optional, Tuple, Union
  import matplotlib
  import matplotlib.pyplot
  import numpy
  from PIL import Image
label_desc: Use image node_id 2 for calling the VideoWriter obj's underlying member method code with example usage: obj.write_frame(frame, resize) without return types