code: def method(*args, **kwargs):
      """Annotate an actor method.
  
      .. code-block:: python
  
          @ray.remote
          class Foo:
              @ray.method(num_returns=2)
              def bar(self):
                  return 1, 2
  
          f = Foo.remote()
  
          _, _ = f.bar.remote()
  
      Args:
          num_returns: The number of object refs that should be returned by
              invocations of this actor method.
      """
      valid_kwargs = [
          "num_returns",
          "concurrency_group",
          "_max_retries",
          "retry_exceptions",
          "_generator_backpressure_num_objects",
      ]
      error_string = (
          "The @ray.method decorator must be applied using at least one of "
          f"the arguments in the list {valid_kwargs}, for example "
          "'@ray.method(num_returns=2)'."
      )
      assert len(args) == 0 and len(kwargs) > 0, error_string
      for key in kwargs:
          key_error_string = (
              f"Unexpected keyword argument to @ray.method: '{key}'. The "
              f"supported keyword arguments are {valid_kwargs}"
          )
          assert key in valid_kwargs, key_error_string
  
      def annotate_method(method):
          if "num_returns" in kwargs:
              method.__ray_num_returns__ = kwargs["num_returns"]
          if "_max_retries" in kwargs:
              method.__ray_max_retries__ = kwargs["_max_retries"]
          if "retry_exceptions" in kwargs:
              method.__ray_retry_exceptions__ = kwargs[
                  "retry_exceptions"
              ]
          if "concurrency_group" in kwargs:
              method.__ray_concurrency_group__ = kwargs[
                  "concurrency_group"
              ]
          if "_generator_backpressure_num_objects" in kwargs:
              method.__ray_generator_backpressure_num_objects__ = (
                  kwargs["_generator_backpressure_num_objects"]
              )
          return method
  
      return annotate_method
  
imports: import inspect
  import logging
  import weakref
  from typing import Any, Dict, List, Optional, Union
  import ray._private.ray_constants
  import ray._private.signature
  import ray._private.worker
  import ray._raylet
  from ray import ActorClassID, Language, cross_language
  from ray._private import ray_option_utils
  from ray._private.async_compat import is_async_func
  from ray._private.auto_init_hook import wrap_auto_init
  from ray._private.client_mode_hook import client_mode_convert_actor, client_mode_hook, client_mode_should_convert
  from ray._private.inspect_util import is_class_method, is_function_or_method, is_static_method
  from ray._private.ray_option_utils import _warn_if_using_deprecated_placement_group
  from ray._private.utils import get_runtime_env_info, parse_runtime_env
  from ray._raylet import STREAMING_GENERATOR_RETURN, ObjectRefGenerator, PythonFunctionDescriptor, raise_sys_exit_with_custom_error_message
  from ray.exceptions import AsyncioActorExit
  from ray.util.annotations import DeveloperAPI, PublicAPI
  from ray.util.placement_group import _configure_placement_group_based_on_context
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy, SchedulingStrategyT
  from ray.util.tracing.tracing_helper import _inject_tracing_into_class, _tracing_actor_creation, _tracing_actor_method_invocation
label_desc: Use image node_id 1 for calling a global function with example usage: method() and returns: annotate_method, method