code: def create(
      cls,
      deployment_name: str,
      bento: Tag | str,
      description: str | None = None,
      expose_endpoint: bool | None = None,
      cluster_name: str | None = None,
      kube_namespace: str | None = None,
      resource_instance: str | None = None,
      hpa_conf: DeploymentTargetHPAConf | None = None,
      runners_config: dict[str, DeploymentTargetRunnerConfig]
      | None = None,
      api_server_config: DeploymentTargetConfig | None = None,
      mode: DeploymentMode | None = None,
      type: DeploymentTargetType | None = None,
      context: str | None = None,
      labels: dict[str, str] | None = None,
      canary_rules: t.List[DeploymentTargetCanaryRule] | None = None,
  ) -> DeploymentSchema:
      if mode is None:
          mode = DeploymentMode.Function
      if type is None:
          type = DeploymentTargetType.STABLE
      bento_tag = Tag.from_taglike(bento)
  
      dct: dict[str, t.Any] = {
          "name": deployment_name,
          "kube_namespace": kube_namespace,
          "mode": mode,
          "description": description,
      }
      if labels:
          dct["labels"] = [
              {"key": key, "value": value}
              for key, value in labels.items()
          ]
      if api_server_config is None:
          _config: dict[str, t.Any] = {
              "runners": {
                  k: bentoml_cattr.unstructure(v)
                  for k, v in runners_config.items()
              }
              if runners_config
              else None,
          }
      else:
          api_server_config.runners = runners_config
          _config = bentoml_cattr.unstructure(api_server_config)
  
      create_target: dict[str, t.Any] = {
          "type": type,
          "bento_repository": bento_tag.name,
          "bento": bento_tag.version,
          "config": _config,
      }
      if canary_rules:
          create_target["canary_rules"] = [
              bentoml_cattr.unstructure(i) for i in canary_rules
          ]
  
      # Only change the value by the top-level param if it is not provided already in api_server_config or runner_config
      if hpa_conf:
          hpa_conf_dct = bentoml_cattr.unstructure(hpa_conf)
          _config_hpa_conf = _config.get("hpa_conf", None)
          if _config_hpa_conf is None:
              _config_hpa_conf = {}
          for k, v in hpa_conf_dct.items():
              if k not in _config_hpa_conf:
                  _config_hpa_conf[k] = v
              else:
                  logger.warning(
                      "Key %s is already set in API server config and will not be overwritten with hpa_conf.%s",
                      k,
                      k,
                  )
          _config["hpa_conf"] = _config_hpa_conf
          if "runners" in _config and _config["runners"] is not None:
              _runner_config = _config["runners"]
              for runner in _runner_config.values():
                  _runner_hpa_conf = runner.get("hpa_conf", None)
                  if _runner_hpa_conf is None:
                      _runner_hpa_conf = {}
                  for k, v in hpa_conf_dct.items():
                      if k not in _runner_hpa_conf:
                          _runner_hpa_conf[k] = v
                      else:
                          logger.warning(
                              "Key %s is already set in runner config and will not be overwritten with hpa_conf.%s",
                              k,
                              k,
                          )
                  runner["hpa_conf"] = _runner_hpa_conf
  
      if resource_instance:
          if "resource_instance" not in _config:
              _config["resource_instance"] = resource_instance
          if "runners" in _config and _config["runners"] is not None:
              for runner in _config["runners"].values():
                  if "resource_instance" not in runner:
                      runner["resource_instance"] = resource_instance
  
      if (
          expose_endpoint is not None
          and _config.get("enable_ingress", None) is None
      ):
          _config["enable_ingress"] = expose_endpoint
  
      # setup the create target itself
      dct["targets"] = [create_target]
  
      return cls._create_deployment(
          context=context,
          cluster_name=cluster_name,
          create_deployment_schema=bentoml_cattr.structure(
              dct, CreateDeploymentSchema
          ),
      )
  
imports: from __future__ import annotations
  import json
  import logging
  import typing
  import attr
  from deepmerge.merger import Merger
  from ...exceptions import BentoMLException
  from ..tag import Tag
  from ..utils import bentoml_cattr
  from ..utils import first_not_none
  from ..utils import resolve_user_filepath
  from .config import get_rest_api_client
  from .schemas import CreateDeploymentSchema
  from .schemas import DeploymentListSchema
  from .schemas import DeploymentMode
  from .schemas import DeploymentSchema
  from .schemas import DeploymentTargetCanaryRule
  from .schemas import DeploymentTargetConfig
  from .schemas import DeploymentTargetHPAConf
  from .schemas import DeploymentTargetRunnerConfig
  from .schemas import DeploymentTargetType
  from .schemas import FullDeploymentSchema
  from .schemas import UpdateDeploymentSchema
label_desc: Use image node_id 6 for calling the Deployment obj's underlying member method code with example usage: obj.create(cls, deployment_name, bento, description, expose_endpoint, cluster_name, kube_namespace, resource_instance, hpa_conf, runners_config, api_server_config, mode, type, context, labels, canary_rules) and returns: cls