<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cleanup(self, force=False, delete=False):
 """ Stop container and delete image if given param delete :param force: bool, force stop and delete, no errors raised :param delete: delete images :return: None """

        # TODO: this method could be part of API, like:
        try:
            self.stop()
        except subprocess.CalledProcessError as stop:
            logger.debug("unable to stop container via stop", stop)
            if not force:
                raise stop
            try:
                self.kill()
            except subprocess.CalledProcessError as kill:
                logger.debug("unable to stop container via kill", kill)
                pass
        if delete:
            self.delete(force=force)