class_docstr: Wraps a user-provided callable that is used to handle requests to a replica.
class_docstr_tok: ["Wraps","a","user-provided","callable","that","is","used","to","handle","requests","to","a","replica","."]
code: def __init__(
      self,
      deployment_def: Callable,
      init_args: Tuple,
      init_kwargs: Dict,
      *,
      deployment_id: DeploymentID,
      event_loop: asyncio.AbstractEventLoop,
  ):
      if not (
          inspect.isfunction(deployment_def)
          or inspect.isclass(deployment_def)
      ):
          raise TypeError(
              "deployment_def must be a function or class. Instead, its type was "
              f"{type(deployment_def)}."
          )
  
      self._deployment_def = deployment_def
      self._init_args = init_args
      self._init_kwargs = init_kwargs
      self._is_function = inspect.isfunction(deployment_def)
      self._deployment_id = deployment_id
      self._event_loop = event_loop
      self._delete_lock = asyncio.Lock()
  
      # Will be populated in `initialize_callable`.
      self._callable = None
  
imports: import asyncio
  import inspect
  import logging
  import os
  import pickle
  import time
  import traceback
  from contextlib import contextmanager
  from importlib import import_module
  from typing import Any, AsyncGenerator, Callable, Dict, Optional, Tuple, Union
  import starlette.responses
  import ray
  from ray import cloudpickle
  from ray._private.utils import get_or_create_event_loop
  from ray.actor import ActorClass
  from ray.remote_function import RemoteFunction
  from ray.serve import metrics
  from ray.serve._private.autoscaling_metrics import InMemoryMetricsStore
  from ray.serve._private.common import DeploymentID, ReplicaName, ReplicaTag, ServeComponentType, StreamingHTTPRequest, gRPCRequest
  from ray.serve._private.config import DeploymentConfig
  from ray.serve._private.constants import DEFAULT_LATENCY_BUCKET_MS, GRPC_CONTEXT_ARG_NAME, HEALTH_CHECK_METHOD, RAY_SERVE_GAUGE_METRIC_SET_PERIOD_S, RAY_SERVE_REPLICA_AUTOSCALING_METRIC_RECORD_PERIOD_S, RECONFIGURE_METHOD, REPLICA_CONTROL_PLANE_CONCURRENCY_GROUP, SERVE_CONTROLLER_NAME, SERVE_LOGGER_NAME, SERVE_NAMESPACE
  from ray.serve._private.http_util import ASGIAppReplicaWrapper, ASGIArgs, ASGIReceiveProxy, MessageQueue, Response
  from ray.serve._private.logging_utils import access_log_msg, configure_component_cpu_profiler, configure_component_logger, configure_component_memory_profiler, get_component_logger_file_path
  from ray.serve._private.router import RequestMetadata
  from ray.serve._private.utils import MetricsPusher, merge_dict, parse_import_path, wrap_to_ray_error
  from ray.serve._private.version import DeploymentVersion
  from ray.serve.config import AutoscalingConfig
  from ray.serve.deployment import Deployment
  from ray.serve.exceptions import RayServeException
  from ray.serve.schema import LoggingConfig
label_desc: Use image node_id 1 to create a new UserCallableWrapper object  with example: obj = UserCallableWrapper(deployment_def, init_args, init_kwargs)