code: def _imgdata(self, width, height,
                   state_size=None, start='', dataset=''):
          
          size = width * height
          if size > 0 and start:
              yield state_to_pixel(start)
              size -= 1
  
          while size > 0:
              prev_size = size
  
              pixels = self.generate(state_size, start, dataset)
              pixels = islice(pixels, 0, size)
  
              for pixel in pixels:
                  yield state_to_pixel(pixel)
                  size -= 1
  
              if prev_size == size:
                  if start:
                      yield from repeat(state_to_pixel(start), size)
                  else:
                      raise RuntimeError('empty generator')
docs: Generate image pixels.
  
          Parameters
          ----------
          width : `int`
              Image width.
          height : `int`
              Image height.
          state_size : `int` or `None`, optional
              State size to use for generation (default: `None`).
          start : `str`, optional
              Initial state (default: '').
          dataset : `str`, optional
              Dataset key prefix (default: '').
  
          Raises
          ------
          RuntimeError
              If generator is empty.
  
          Returns
          -------
          `generator` of `int`
              Pixel generator.