code: def _convert_python_version(py_version: str | None) -> str | None:
      if py_version is None:
          return None
  
      if not isinstance(py_version, str):
          py_version = str(py_version)
  
      match = re.match(r"^(\d{1})\.(\d{,2})(?:\.\w+)?$", py_version)
      if match is None:
          raise InvalidArgument(
              f'Invalid build option: docker.python_version="{py_version}", python '
              "version must follow standard python semver format, e.g. 3.8.15",
          )
      major, minor = match.groups()
      target_python_version = f"{major}.{minor}"
      if target_python_version != py_version:
          logger.warning(
              "BentoML will install the latest 'python%s' instead of the specified 'python%s'. To use the exact python version, use a custom docker base image. See https://docs.bentoml.com/en/latest/concepts/bento.html#custom-base-image-advanced",
              target_python_version,
              py_version,
          )
      return target_python_version
  
imports: from __future__ import annotations
  import logging
  import os
  import re
  import subprocess
  import sys
  import typing
  from shlex import quote
  from sys import version_info
  import attr
  import fs
  import fs.copy
  import psutil
  import yaml
  from pathspec import PathSpec
  from ...exceptions import BentoMLException
  from ...exceptions import InvalidArgument
  from ..configuration import BENTOML_VERSION
  from ..configuration import clean_bentoml_version
  from ..configuration import get_quiet_mode
  from ..container import generate_containerfile
  from ..container.frontend.dockerfile import ALLOWED_CUDA_VERSION_ARGS
  from ..container.frontend.dockerfile import CONTAINER_SUPPORTED_DISTROS
  from ..container.frontend.dockerfile import SUPPORTED_CUDA_VERSIONS
  from ..container.frontend.dockerfile import DistroSpec
  from ..container.frontend.dockerfile import get_supported_spec
  from ..container.generate import BENTO_PATH
  from ..utils import bentoml_cattr
  from ..utils import copy_file_to_fs_folder
  from ..utils import resolve_user_filepath
  from ..utils.dotenv import parse_dotenv
  from .build_dev_bentoml_whl import build_bentoml_editable_wheel
label_desc: Use image node_id 1 for calling a global function with example usage: _convert_python_version(py_version) and returns: target_python_version, None