code: def check_version(self, node_id=None, timeout=2, strict=False):
          
          self._lock.acquire()
          end = time.time() + timeout
          while time.time() < end:
  
              # It is possible that least_loaded_node falls back to bootstrap,
              # which can block for an increasing backoff period
              try_node = node_id or self.least_loaded_node()
              if try_node is None:
                  self._lock.release()
                  raise Errors.NoBrokersAvailable()
              self._maybe_connect(try_node)
              conn = self._conns[try_node]
  
              # We will intentionally cause socket failures
              # These should not trigger metadata refresh
              self._refresh_on_disconnects = False
              try:
                  remaining = end - time.time()
                  version = conn.check_version(timeout=remaining, strict=strict, topics=list(self.config['bootstrap_topics_filter']))
                  if version >= (0, 10, 0):
                      # cache the api versions map if it's available (starting
                      # in 0.10 cluster version)
                      self._api_versions = conn.get_api_versions()
                  self._lock.release()
                  return version
              except Errors.NodeNotReadyError:
                  # Only raise to user if this is a node-specific request
                  if node_id is not None:
                      self._lock.release()
                      raise
              finally:
                  self._refresh_on_disconnects = True
  
          # Timeout
          else:
              self._lock.release()
              raise Errors.NoBrokersAvailable()
docs: Attempt to guess the version of a Kafka broker.
  
          Note: It is possible that this method blocks longer than the
              specified timeout. This can happen if the entire cluster
              is down and the client enters a bootstrap backoff sleep.
              This is only possible if node_id is None.
  
          Returns: version tuple, i.e. (0, 10), (0, 9), (0, 8, 2), ...
  
          Raises:
              NodeNotReadyError (if node_id is provided)
              NoBrokersAvailable (if node_id is None)
              UnrecognizedBrokerVersion: please file bug if seen!
              AssertionError (if strict=True): please file bug if seen!