code: def _check_modes(self, modes):
          
          if not isinstance(modes, (tuple, list, set)):
              modes = [modes]
          if self.mode not in modes:
              raise ValueError("Image not in suitable mode, expected: %s, got: %s" % (modes, self.mode))
docs: Check that the image is in one of the given *modes*, raise an exception otherwise.