def get_templates_variables(
    docker: DockerOptions,
    conda: CondaOptions,
    bento_fs: FS,
    *,
    python_packages: dict[str, str] | None = None,
    _is_cuda: bool = False,
    **bento_env: str | bool,
) -> dict[str, t.Any]:
    """
    Returns a dictionary of variables to be used in BentoML base templates.
    """
    conda_python_version = conda.get_python_version(bento_fs)
    if conda_python_version is None:
        conda_python_version = docker.python_version

    if docker.base_image is not None:
        base_image = docker.base_image
        logger.info(
            "BentoML will not install Python to custom base images; ensure the base image '%s' has Python installed.",
            base_image,
        )
    else:
        spec = DistroSpec.from_options(docker, conda)
        python_version = docker.python_version
        assert docker.distro is not None and python_version is not None
        if docker.distro in ("ubi8",):
            # ubi8 base images uses "py38" instead of "py3.8" in its image tag
            python_version = python_version.replace(".", "")
        base_image = spec.image.format(spec_version=python_version)
        if docker.cuda_version is not None:
            base_image = spec.image.format(spec_version=docker.cuda_version)

    # bento__env
    default_env = {**DEFAULT_BENTO_ENVS, **bento_env}

    return {
        **{to_options_field(k): v for k, v in docker.to_dict().items()},
        **{to_bento_field(k): v for k, v in default_env.items()},
        "__prometheus_port__": BentoMLContainer.grpc.metrics.port.get(),
        "__base_image__": base_image,
        "__conda_python_version__": conda_python_version,
        "__is_cuda__": _is_cuda,
        "__pip_preheat_packages__": [
            python_packages[k]
            for k in PREHEAT_PIP_PACKAGES
            if python_packages and python_packages.get(k)
        ],
    }
Returns a dictionary of variables to be used in BentoML base templates.
src/bentoml/_internal/container/generate.py