code: def check_client_server_compatibility(
      client_version: Optional[str],
      server_version: Optional[str],
  ) -> Optional[JSONResponse]:
      """
      Returns `JSONResponse` with error if client/server versions are incompatible.
      Returns `None` otherwise.
      """
      if server_version is None:
          return None
      parsed_server_version = version.parse(server_version)
      if client_version is None:
          return error_incompatible_versions(
              client_version, server_version, ask_cli_update=True
          )
      # latest allows client to bypass compatibility check (e.g. frontend)
      if client_version == "latest":
          return None
      try:
          parsed_client_version = version.parse(client_version)
      except version.InvalidVersion:
          return JSONResponse(
              status_code=status.HTTP_400_BAD_REQUEST,
              content={
                  "detail": get_server_client_error_details(
                      ServerClientError("Bad API version specified")
                  )
              },
          )
      if parsed_client_version < parsed_server_version and (
          parsed_client_version.major < parsed_server_version.major
          or parsed_client_version.minor < parsed_server_version.minor
      ):
          return error_incompatible_versions(
              client_version, server_version, ask_cli_update=True
          )
      elif parsed_client_version > parsed_server_version and (
          parsed_client_version.major > parsed_server_version.major
          or parsed_client_version.minor > parsed_server_version.minor
      ):
          return error_incompatible_versions(
              client_version, server_version, ask_cli_update=False
          )
      return None
  
file_path: dstack/src/dstack/_internal/server/utils/routers.py
imports: from typing import Dict, List, Optional
  from fastapi import HTTPException, Request, Response, status
  from fastapi.responses import JSONResponse
  from packaging import version
  from dstack._internal.core.errors import ServerClientError
  from dstack._internal.server import settings
label_desc: Use image node_id 8 for calling a global function with example usage: check_client_server_compatibility(client_version, server_version) and returns: None, None, error_incompatible_versions, None, error_incompatible_versions, JSONResponse, error_incompatible_versions