class_docstr: Config for the Serve Autoscaler.
docstr: Serialize policy with cloudpickle.
  
  Import the policy if it's passed in as a string import path. Then cloudpickle
  the policy and set `serialized_policy_def` if it's empty.
docstr_tok: ["Serialize","policy","with","cloudpickle",".","Import","the","policy","if","it","'s","passed","in","as","a","string","import","path",".","Then","cloudpickle","the","policy","and","set","`","serialized_policy_def","`","if","it","'s","empty","."]
code: def serialize_policy(cls, policy, values) -> str:
      """Serialize policy with cloudpickle.
  
      Import the policy if it's passed in as a string import path. Then cloudpickle
      the policy and set `serialized_policy_def` if it's empty.
      """
      if isinstance(policy, Callable):
          policy = f"{policy.__module__}.{policy.__name__}"
  
      if not policy:
          policy = DEFAULT_AUTOSCALING_POLICY
  
      policy_path = policy
      policy = import_attr(policy)
  
      if not values.get("serialized_policy_def"):
          values["serialized_policy_def"] = cloudpickle.dumps(policy)
  
      return policy_path
  
imports: import logging
  import warnings
  from enum import Enum
  from typing import Any, Callable, List, Optional, Union
  from ray import cloudpickle
  from ray._private.pydantic_compat import BaseModel, NonNegativeFloat, NonNegativeInt, PositiveFloat, PositiveInt, validator
  from ray._private.utils import import_attr
  from ray.serve._private.constants import DEFAULT_AUTOSCALING_POLICY, DEFAULT_GRPC_PORT, DEFAULT_HTTP_HOST, DEFAULT_HTTP_PORT, DEFAULT_UVICORN_KEEP_ALIVE_TIMEOUT_S, SERVE_LOGGER_NAME
  from ray.util.annotations import Deprecated, PublicAPI
label_desc: Use image node_id 2 for calling the AutoscalingConfig obj's underlying member method code with example usage: obj.serialize_policy(cls, policy, values) and returns: policy_path