code: def _ensure_empty_image_ok(self):
          
          if self.ignore_empty:
              return
  
          if len(self) > 1:
              raise RuntimeError(
                  "Cannot write None image at extension %d" % len(self))
          if 'ndims' in self[0]._info:
              raise RuntimeError("Can only write None images to extension zero, "
                                 "which already exists")
docs: If ignore_empty was not set to True, we only allow empty HDU for first
          HDU and if there is no data there already