class_docstr: Code to visualize an agent's behaviour.
class_docstr_tok: ["Code","to","visualize","an","agent","'s","behaviour","."]
docstr: Save a frame to disk and generate a video, if enabled.
docstr_tok: ["Save","a","frame","to","disk","and","generate","a","video",",","if","enabled","."]
code: def save_frame(self):
      """Save a frame to disk and generate a video, if enabled."""
      screen_buffer = np.frombuffer(
          self.screen.get_buffer(), dtype=np.int32
      ).reshape(self.screen_height, self.screen_width)
      sb = screen_buffer[:, 0 : self.screen_width]
      self.record_frame[..., 2] = sb % 256
      self.record_frame[..., 1] = (sb >> 8) % 256
      self.record_frame[..., 0] = (sb >> 16) % 256
      frame_number = self.step // self.render_rate
      for file_type in self.file_types:
          if not file_type:
              continue
          filename = self.filename_format.format(
              frame_number
          ) + ".{}".format(file_type)
          im = Image.fromarray(self.record_frame)
          im.save(os.path.join(self.record_path, filename))
  
file_path: dopamine/dopamine/utils/agent_visualizer.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import subprocess
  import gin
  import numpy
  from PIL import Image
  import pygame
label_desc: Use image node_id 3 for calling the AgentVisualizer obj's underlying member method code with example usage: obj.save_frame() without return types