class_docstr: Logger for writing NumPy arrays as PNG images to disk.
  
  Assumes that all data passed are NumPy arrays that can be converted to images.
  
  TODO(jaslanides): Make this stateless/robust to preemptions.
class_docstr_tok: ["Logger","for","writing","NumPy","arrays","as","PNG","images","to","disk",".","Assumes","that","all","data","passed","are","NumPy","arrays","that","can","be","converted","to","images",".","TODO","(","jaslanides",")",":","Make","this","stateless\/robust","to","preemptions","."]
docstr: Initialises the writer.
  
  Args:
    directory: Base directory to which images are logged.
    label: Optional subdirectory in which to save images.
    mode: Image mode for use with Pillow. If `None` (default), mode is
      determined by data type. See [0] for details.
  
  [0] https://pillow.readthedocs.io/en/stable/handbook/concepts.html#modes
docstr_tok: ["Initialises","the","writer",".","Args",":","directory",":","Base","directory","to","which","images","are","logged",".","label",":","Optional","subdirectory","in","which","to","save","images",".","mode",":","Image","mode","for","use","with","Pillow",".","If","`","None","`","(","default",")",",","mode","is","determined","by","data","type",".","See","[","0","]","for","details",".","[","0","]","https",":","\/\/pillow.readthedocs.io\/en\/stable\/handbook\/concepts.html","#","modes"]
code: def __init__(
      self,
      directory: str,
      *,
      label: str = "",
      mode: Optional[str] = None,
  ):
      """Initialises the writer.
  
      Args:
        directory: Base directory to which images are logged.
        label: Optional subdirectory in which to save images.
        mode: Image mode for use with Pillow. If `None` (default), mode is
          determined by data type. See [0] for details.
  
      [0] https://pillow.readthedocs.io/en/stable/handbook/concepts.html#modes
      """
  
      self._path = self._get_path(directory, label)
      if not self._path.exists():
          self._path.mkdir(parents=True)
  
      self._mode = mode
      self._indices = collections.defaultdict(int)
  
file_path: acme/acme/utils/loggers/image.py
imports: import collections
  import pathlib
  from typing import Optional
  from absl import logging
  from acme.utils.loggers import base
  from PIL import Image
label_desc: Use image node_id 1 to create a new ImageLogger object from inherited base classes: base with example: obj = ImageLogger(directory)