code: def _create_deployment(
      cls,
      create_deployment_schema: CreateDeploymentSchema,
      context: str | None = None,
      cluster_name: str | None = None,
  ) -> DeploymentSchema:
      cloud_rest_client = get_rest_api_client(context)
      if cluster_name is None:
          cluster_name = cls._get_default_cluster(context)
      if create_deployment_schema.kube_namespace is None:
          create_deployment_schema.kube_namespace = (
              cls._get_default_kube_namespace(cluster_name, context)
          )
      for target in create_deployment_schema.targets:
          if (
              cloud_rest_client.get_bento(
                  target.bento_repository, target.bento
              )
              is None
          ):
              raise BentoMLException(
                  f"Create deployment: {target.bento_repository}:{target.bento} does not exist"
              )
      if (
          cloud_rest_client.get_deployment(
              cluster_name,
              create_deployment_schema.kube_namespace,
              create_deployment_schema.name,
          )
          is not None
      ):
          raise BentoMLException(
              "Create deployment: Deployment already exists"
          )
      res = cloud_rest_client.create_deployment(
          cluster_name, create_deployment_schema
      )
      if res is None:
          raise BentoMLException("Create deployment request failed")
      logger.debug("Deployment Schema: %s", create_deployment_schema)
      return res
  
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 3 for calling the Deployment obj's underlying member method code with example usage: obj._create_deployment(cls, create_deployment_schema, context, cluster_name) and returns: res