code: def deployment(
      target: str | Tag | bentoml.Bento | bentoml.Service,
      service_deployment_config: dict[str, t.Any] | None = None,
      runners_deployment_config_map: dict[str, dict[str, t.Any]]
      | None = None,
      enable_batching: bool = False,
      batching_config: dict[str, dict[str, dict[str, float | int]]]
      | None = None,
  ) -> Deployment:
      """
      Deploy a Bento or bentoml.Service to Ray
  
      Args:
          target: A bentoml.Service instance, Bento tag string, or Bento object
          service_deployment_config: Ray deployment config for BentoML API server
          runners_deployment_config_map: Ray deployment config map for all Runners
          enable_batching: Enable Ray Serve batching for RunnerMethods with batchable=True
          batching_config: Pass through Ray batching config by Runner name and method name
  
      Returns:
          A bound ray.serve.Deployment instance
  
      Example:
  
      .. code-block:: python
          :caption: `ray_demo.py`
  
          import bentoml
  
          classifier = bentoml.ray.deployment('iris_classifier:latest')
  
      .. code-block:: bash
  
          serve run ray_demo:classifier
  
      Configure BentoML-on-Ray deployment:
  
      .. code-block:: python
  
          import bentoml
  
          classifier = bentoml.ray.deployment(
              'iris_classifier:latest',
              {"route_prefix": "/hello", "num_replicas": 3, "ray_actor_options": {"num_cpus": 1}},
              {"iris_clf": {"num_replicas": 1, "ray_actor_options": {"num_cpus": 5}}}
          )
  
      Configure BentoML Runner's Batching behavior on Ray:
  
      .. code-block:: python
  
          import bentoml
  
          deploy = bentoml.ray.deployment(
              'fraud_detection:latest',
              {"num_replicas": 5, "ray_actor_options": {"num_cpus": 1}},
              {"ieee-fraud-detection-sm": {"num_replicas": 1, "ray_actor_options": {"num_cpus": 5}}},
              enable_batching=True,
              batching_config={"ieee-fraud-detection-sm": {"predict_proba": {"max_batch_size": 5, "batch_wait_timeout_s": 0.2}}}
          )
  
      """
      # TODO: validate Ray deployment options
      service_deployment_config = service_deployment_config or {}
  
      svc = (
          target
          if isinstance(target, bentoml.Service)
          else bentoml.load(target)
      )
  
      runner_deployments = _deploy_bento_runners(
          svc,
          runners_deployment_config_map,
          enable_batching,
          batching_config,
      )
  
      return _get_service_deployment(
          svc, **service_deployment_config
      ).bind(**runner_deployments)
  
file_path: BentoML/grpc-client/bentoml/_internal/ray/__init__.py
imports: from __future__ import annotations
  import typing
  from functools import partial
  import requests
  from ..._internal.utils import pkg
  import bentoml
  from bentoml import Tag
  from ...exceptions import MissingDependencyException
  from ..runner.container import AutoContainer
  from ..runner.utils import Params
  from .runner_handle import RayRunnerHandle
label_desc: Use image node_id 5 for calling a global function with example usage: deployment(target, service_deployment_config, runners_deployment_config_map, enable_batching, batching_config) and returns: _get_service_deployment