class_docstr: A remote function.
  
  This is a decorated function. It can be used to spawn tasks.
  
  Attributes:
      _language: The target language.
      _function: The original function.
      _function_descriptor: The function descriptor. This is not defined
          until the remote function is first invoked because that is when the
          function is pickled, and the pickled function is used to compute
          the function descriptor.
      _function_name: The module and function name.
      _num_cpus: The default number of CPUs to use for invocations of this
          remote function.
      _num_gpus: The default number of GPUs to use for invocations of this
          remote function.
      _memory: The heap memory request in bytes for this task/actor,
          rounded down to the nearest integer.
      _resources: The default custom resource requirements for invocations of
          this remote function.
      _num_returns: The default number of return values for invocations
          of this remote function.
      _max_calls: The number of times a worker can execute this function
          before exiting.
      _max_retries: The number of times this task may be retried
          on worker failure.
      _retry_exceptions: Whether application-level errors should be retried.
          This can be a boolean or a list/tuple of exceptions that should be retried.
      _runtime_env: The runtime environment for this task.
      _decorator: An optional decorator that should be applied to the remote
          function invocation (as opposed to the function execution) before
          invoking the function. The decorator must return a function that
          takes in two arguments ("args" and "kwargs"). In most cases, it
          should call the function that was passed into the decorator and
          return the resulting ObjectRefs. For an example, see
          "test_decorated_function" in "python/ray/tests/test_basic.py".
      _function_signature: The function signature.
      _last_export_session_and_job: A pair of the last exported session
          and job to help us to know whether this function was exported.
          This is an imperfect mechanism used to determine if we need to
          export the remote function again. It is imperfect in the sense that
          the actor class definition could be exported multiple times by
          different workers.
      _scheduling_strategy: Strategy about how to schedule
          this remote function.
class_docstr_tok: ["A","remote","function",".","This","is","a","decorated","function",".","It","can","be","used","to","spawn","tasks",".","Attributes",":","_language",":","The","target","language",".","_function",":","The","original","function",".","_function_descriptor",":","The","function","descriptor",".","This","is","not","defined","until","the","remote","function","is","first","invoked","because","that","is","when","the","function","is","pickled",",","and","the","pickled","function","is","used","to","compute","the","function","descriptor",".","_function_name",":","The","module","and","function","name",".","_num_cpus",":","The","default","number","of","CPUs","to","use","for","invocations","of","this","remote","function",".","_num_gpus",":","The","default","number","of","GPUs","to","use","for","invocations","of","this","remote","function",".","_memory",":","The","heap","memory","request","in","bytes","for","this","task\/actor",",","rounded","down","to","the","nearest","integer",".","_resources",":","The","default","custom","resource","requirements","for","invocations","of","this","remote","function",".","_num_returns",":","The","default","number","of","return","values","for","invocations","of","this","remote","function",".","_max_calls",":","The","number","of","times","a","worker","can","execute","this","function","before","exiting",".","_max_retries",":","The","number","of","times","this","task","may","be","retried","on","worker","failure",".","_retry_exceptions",":","Whether","application-level","errors","should","be","retried",".","This","can","be","a","boolean","or","a","list\/tuple","of","exceptions","that","should","be","retried",".","_runtime_env",":","The","runtime","environment","for","this","task",".","_decorator",":","An","optional","decorator","that","should","be","applied","to","the","remote","function","invocation","(","as","opposed","to","the","function","execution",")","before","invoking","the","function",".","The","decorator","must","return","a","function","that","takes","in","two","arguments","(","``","args","''","and","``","kwargs","''",")",".","In","most","cases",",","it","should","call","the","function","that","was","passed","into","the","decorator","and","return","the","resulting","ObjectRefs",".","For","an","example",",","see","``","test_decorated_function","''","in","``","python\/ray\/tests\/test_basic.py","''",".","_function_signature",":","The","function","signature",".","_last_export_session_and_job",":","A","pair","of","the","last","exported","session","and","job","to","help","us","to","know","whether","this","function","was","exported",".","This","is","an","imperfect","mechanism","used","to","determine","if","we","need","to","export","the","remote","function","again",".","It","is","imperfect","in","the","sense","that","the","actor","class","definition","could","be","exported","multiple","times","by","different","workers",".","_scheduling_strategy",":","Strategy","about","how","to","schedule","this","remote","function","."]
docstr: Configures and overrides the task invocation parameters.
  
  The arguments are the same as those that can be passed to :obj:`ray.remote`.
  Overriding `max_calls` is not supported.
  
  Args:
      num_returns: It specifies the number of object refs returned by
          the remote function invocation.
      num_cpus: The quantity of CPU cores to reserve
          for this task or for the lifetime of the actor.
      num_gpus: The quantity of GPUs to reserve
          for this task or for the lifetime of the actor.
      resources (Dict[str, float]): The quantity of various custom resources
          to reserve for this task or for the lifetime of the actor.
          This is a dictionary mapping strings (resource names) to floats.
      accelerator_type: If specified, requires that the task or actor run
          on a node with the specified type of accelerator.
          See :ref:`accelerator types <accelerator_types>`.
      memory: The heap memory request in bytes for this task/actor,
          rounded down to the nearest integer.
      object_store_memory: The object store memory request for actors only.
      max_calls: This specifies the
          maximum number of times that a given worker can execute
          the given remote function before it must exit
          (this can be used to address memory leaks in third-party
          libraries or to reclaim resources that cannot easily be
          released, e.g., GPU memory that was acquired by TensorFlow).
          By default this is infinite for CPU tasks and 1 for GPU tasks
          (to force GPU tasks to release resources after finishing).
      max_retries: This specifies the maximum number of times that the remote
          function should be rerun when the worker process executing it
          crashes unexpectedly. The minimum valid value is 0,
          the default is 3 (default), and a value of -1 indicates
          infinite retries.
      runtime_env (Dict[str, Any]): Specifies the runtime environment for
          this actor or task and its children. See
          :ref:`runtime-environments` for detailed documentation.
      retry_exceptions: This specifies whether application-level errors
          should be retried up to max_retries times.
      scheduling_strategy: Strategy about how to
          schedule a remote function or actor. Possible values are
          None: ray will figure out the scheduling strategy to use, it
          will either be the PlacementGroupSchedulingStrategy using parent's
          placement group if parent has one and has
          placement_group_capture_child_tasks set to true,
          or "DEFAULT";
          "DEFAULT": default hybrid scheduling;
          "SPREAD": best effort spread scheduling;
          `PlacementGroupSchedulingStrategy`:
          placement group based scheduling;
          `NodeAffinitySchedulingStrategy`:
          node id based affinity scheduling.
      _metadata: Extended options for Ray libraries. For example,
          _metadata={"workflows.io/options": <workflow options>} for
          Ray workflows.
  
  Examples:
  
  .. code-block:: python
  
      @ray.remote(num_gpus=1, max_calls=1, num_returns=2)
      def f():
         return 1, 2
      # Task g will require 2 gpus instead of 1.
      g = f.options(num_gpus=2)
docstr_tok: ["Configures","and","overrides","the","task","invocation","parameters",".","The","arguments","are","the","same","as","those","that","can","be","passed","to",":","obj",":","`","ray.remote","`",".","Overriding","`","max_calls","`","is","not","supported",".","Args",":","num_returns",":","It","specifies","the","number","of","object","refs","returned","by","the","remote","function","invocation",".","num_cpus",":","The","quantity","of","CPU","cores","to","reserve","for","this","task","or","for","the","lifetime","of","the","actor",".","num_gpus",":","The","quantity","of","GPUs","to","reserve","for","this","task","or","for","the","lifetime","of","the","actor",".","resources","(","Dict","[","str",",","float","]",")",":","The","quantity","of","various","custom","resources","to","reserve","for","this","task","or","for","the","lifetime","of","the","actor",".","This","is","a","dictionary","mapping","strings","(","resource","names",")","to","floats",".","accelerator_type",":","If","specified",",","requires","that","the","task","or","actor","run","on","a","node","with","the","specified","type","of","accelerator",".","See",":","ref",":","`","accelerator","types","<","accelerator_types",">","`",".","memory",":","The","heap","memory","request","in","bytes","for","this","task\/actor",",","rounded","down","to","the","nearest","integer",".","object_store_memory",":","The","object","store","memory","request","for","actors","only",".","max_calls",":","This","specifies","the","maximum","number","of","times","that","a","given","worker","can","execute","the","given","remote","function","before","it","must","exit","(","this","can","be","used","to","address","memory","leaks","in","third-party","libraries","or","to","reclaim","resources","that","can","not","easily","be","released",",","e.g.",",","GPU","memory","that","was","acquired","by","TensorFlow",")",".","By","default","this","is","infinite","for","CPU","tasks","and","1","for","GPU","tasks","(","to","force","GPU","tasks","to","release","resources","after","finishing",")",".","max_retries",":","This","specifies","the","maximum","number","of","times","that","the","remote","function","should","be","rerun","when","the","worker","process","executing","it","crashes","unexpectedly",".","The","minimum","valid","value","is","0",",","the","default","is","3","(","default",")",",","and","a","value","of","-1","indicates","infinite","retries",".","runtime_env","(","Dict","[","str",",","Any","]",")",":","Specifies","the","runtime","environment","for","this","actor","or","task","and","its","children",".","See",":","ref",":","`","runtime-environments","`","for","detailed","documentation",".","retry_exceptions",":","This","specifies","whether","application-level","errors","should","be","retried","up","to","max_retries","times",".","scheduling_strategy",":","Strategy","about","how","to","schedule","a","remote","function","or","actor",".","Possible","values","are","None",":","ray","will","figure","out","the","scheduling","strategy","to","use",",","it","will","either","be","the","PlacementGroupSchedulingStrategy","using","parent's","placement","group","if","parent","has","one","and","has","placement_group_capture_child_tasks","set","to","true",",","or","``","DEFAULT","''",";","``","DEFAULT","''",":","default","hybrid","scheduling",";","``","SPREAD","''",":","best","effort","spread","scheduling",";","`","PlacementGroupSchedulingStrategy","`",":","placement","group","based","scheduling",";","`","NodeAffinitySchedulingStrategy","`",":","node","id","based","affinity","scheduling",".","_metadata",":","Extended","options","for","Ray","libraries",".","For","example",",","_metadata=","{","``","workflows.io\/options","''",":","<","workflow","options",">","}","for","Ray","workflows",".","Examples",":","..","code-block",":",":","python","@","ray.remote","(","num_gpus=1",",","max_calls=1",",","num_returns=2",")","def","f","(",")",":","return","1",",","2","#","Task","g","will","require","2","gpus","instead","of","1.","g","=","f.options","(","num_gpus=2",")"]
code: def options(self, **task_options):
      """Configures and overrides the task invocation parameters.
  
      The arguments are the same as those that can be passed to :obj:`ray.remote`.
      Overriding `max_calls` is not supported.
  
      Args:
          num_returns: It specifies the number of object refs returned by
              the remote function invocation.
          num_cpus: The quantity of CPU cores to reserve
              for this task or for the lifetime of the actor.
          num_gpus: The quantity of GPUs to reserve
              for this task or for the lifetime of the actor.
          resources (Dict[str, float]): The quantity of various custom resources
              to reserve for this task or for the lifetime of the actor.
              This is a dictionary mapping strings (resource names) to floats.
          accelerator_type: If specified, requires that the task or actor run
              on a node with the specified type of accelerator.
              See :ref:`accelerator types <accelerator_types>`.
          memory: The heap memory request in bytes for this task/actor,
              rounded down to the nearest integer.
          object_store_memory: The object store memory request for actors only.
          max_calls: This specifies the
              maximum number of times that a given worker can execute
              the given remote function before it must exit
              (this can be used to address memory leaks in third-party
              libraries or to reclaim resources that cannot easily be
              released, e.g., GPU memory that was acquired by TensorFlow).
              By default this is infinite for CPU tasks and 1 for GPU tasks
              (to force GPU tasks to release resources after finishing).
          max_retries: This specifies the maximum number of times that the remote
              function should be rerun when the worker process executing it
              crashes unexpectedly. The minimum valid value is 0,
              the default is 3 (default), and a value of -1 indicates
              infinite retries.
          runtime_env (Dict[str, Any]): Specifies the runtime environment for
              this actor or task and its children. See
              :ref:`runtime-environments` for detailed documentation.
          retry_exceptions: This specifies whether application-level errors
              should be retried up to max_retries times.
          scheduling_strategy: Strategy about how to
              schedule a remote function or actor. Possible values are
              None: ray will figure out the scheduling strategy to use, it
              will either be the PlacementGroupSchedulingStrategy using parent's
              placement group if parent has one and has
              placement_group_capture_child_tasks set to true,
              or "DEFAULT";
              "DEFAULT": default hybrid scheduling;
              "SPREAD": best effort spread scheduling;
              `PlacementGroupSchedulingStrategy`:
              placement group based scheduling;
              `NodeAffinitySchedulingStrategy`:
              node id based affinity scheduling.
          _metadata: Extended options for Ray libraries. For example,
              _metadata={"workflows.io/options": <workflow options>} for
              Ray workflows.
  
      Examples:
  
      .. code-block:: python
  
          @ray.remote(num_gpus=1, max_calls=1, num_returns=2)
          def f():
             return 1, 2
          # Task g will require 2 gpus instead of 1.
          g = f.options(num_gpus=2)
      """
  
      func_cls = self
  
      # override original options
      default_options = self._default_options.copy()
      # max_calls could not be used in ".options()", we should remove it before
      # merging options from '@ray.remote'.
      default_options.pop("max_calls", None)
      updated_options = ray_option_utils.update_options(
          default_options, task_options
      )
      ray_option_utils.validate_task_options(
          updated_options, in_options=True
      )
  
      # only update runtime_env when ".options()" specifies new runtime_env
      if "runtime_env" in task_options:
          updated_options["runtime_env"] = parse_runtime_env(
              updated_options["runtime_env"]
          )
  
      class FuncWrapper:
          def remote(self, *args, **kwargs):
              return func_cls._remote(
                  args=args, kwargs=kwargs, **updated_options
              )
  
          @DeveloperAPI
          def bind(self, *args, **kwargs):
              """
              For Ray DAG building that creates static graph from decorated
              class or functions.
              """
              from ray.dag.function_node import FunctionNode
  
              return FunctionNode(
                  func_cls._function, args, kwargs, updated_options
              )
  
      return FuncWrapper()
  
imports: import inspect
  import logging
  import os
  import uuid
  from functools import wraps
  from threading import Lock
  import ray._private.signature
  from ray import Language, cross_language
  from ray._private import ray_option_utils
  from ray._private.auto_init_hook import wrap_auto_init
  from ray._private.client_mode_hook import client_mode_convert_function, client_mode_should_convert
  from ray._private.ray_option_utils import _warn_if_using_deprecated_placement_group
  from ray._private.serialization import pickle_dumps
  from ray._private.utils import get_runtime_env_info, parse_runtime_env
  from ray._raylet import STREAMING_GENERATOR_RETURN, ObjectRefGenerator, PythonFunctionDescriptor
  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
  from ray.util.tracing.tracing_helper import _inject_tracing_into_function, _tracing_task_invocation
label_desc: Use image node_id 5 for calling the RemoteFunction obj's underlying member method code with example usage: obj.options() and returns: FuncWrapper, func_cls, FunctionNode