<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sanity_checks(self):
 """Implement Docker driver sanity checks."""


        if self._config.state.sanity_checked:
            return

        log.info("Sanity checks: '{}'".format(self._name))

        HAS_DOCKER_PY = None
        try:
            from ansible.module_utils.docker_common import HAS_DOCKER_PY
        except ImportError:

            # ansible 2.8+
            try:
                from ansible.module_utils.docker.common import HAS_DOCKER_PY
            except ImportError:
                pass

        if not HAS_DOCKER_PY:
            msg = ('Missing Docker driver dependency. Please '
                   "install via 'molecule[docker]' or refer to "
                   'your INSTALL.rst driver documentation file')
            sysexit_with_message(msg)

        try:
            import docker
            import requests
            docker_client = docker.from_env()
            docker_client.ping()
        except requests.exceptions.ConnectionError:
            msg = ('Unable to contact the Docker daemon. '
                   'Please refer to https://docs.docker.com/config/daemon/ '
                   'for managing the daemon')
            sysexit_with_message(msg)

        self._config.state.change_state('sanity_checked', True)