class_docstr: Client class for invoking RPCs to the server.
class_docstr_tok: ["Client","class","for","invoking","RPCs","to","the","server","."]
docstr: Create TF RPC client to connect to the given address.
  
  Args:
    rpc_layer: Communication layer between client and server. Only "grpc" rpc
      layer is supported at the moment.
    address: Address of the server to connect the RPC client to.
    name: Name of the RPC Client. You can create multiple clients connecting
      to same server and distinguish them using different names.
    timeout_in_ms: The default timeout to use for outgoing RPCs from client. 0
      indicates no timeout. Exceeding timeout during RPC will raise
      DeadlineExceeded error.
  
  Returns:
    An instance of `tf.distribute.experimental.rpc.Client` with the following
    dynamically added methods for eagerly created clients:
      * `Registered methods` e.g. multiply(**args):
          If Client is created when executing eagerly, client will request the
          list of registered methods from server during client creation.
          The convenience methods for RPCs will be dynamically added to the
          created Client instance.
  
          For example, when a server has method "multiply" registered, the
          client object created in eager mode will have 'multiply' method
          available. Users can use client.multiply(..) to make RPC, instead of
          client.call("multiply", ...)
  
          Both "call" and "multiply" methods are non-blocking i.e. they return
          a StatusOrResult object which should be used to wait for getting
          value or error.
  
          Along with the above, blocking versions of the registered
          methods are also dynamically added to client instance.
          e.g. multiply_blocking(**args). These methods block till the RPC is
          finished and return response for successful RPC. Otherwise raise
          exception.
  
          These methods are not available when Client is created inside a
          tf.function.
  
  Raises:
      A ValueError if rpc_layer other than "grpc" is used. Only GRPC
        is supported at the moment.
      A DeadlineExceeded exception in eager mode if timeout exceeds while
        creating and listing client methods.
  
  Example usage:
    >>> # Have server already started.
    >>> import portpicker
    >>> @tf.function(input_signature=[
    ...      tf.TensorSpec([], tf.int32),
    ...      tf.TensorSpec([], tf.int32)])
    ... def remote_fn(a, b):
    ...   return tf.add(a, b)
  
    >>> port = portpicker.pick_unused_port()
    >>> address = "localhost:{}".format(port)
    >>> server = tf.distribute.experimental.rpc.Server.create("grpc", address)
    >>> server.register("addition", remote_fn)
    >>> server.start()
  
    >>> # Start client
    >>> client = tf.distribute.experimental.rpc.Client.create("grpc",
    ...      address=address, name="test_client")
  
    >>> a = tf.constant(2, dtype=tf.int32)
    >>> b = tf.constant(3, dtype=tf.int32)
  
    >>> result = client.call(
    ...    args=[a, b],
    ...    method_name="addition",
    ...    output_specs=tf.TensorSpec((), tf.int32))
  
    >>> if result.is_ok():
    ...   result.get_value()
  
    >>> result = client.addition(a, b)
  
    >>> if result.is_ok():
    ...   result.get_value()
  
    >>> value = client.addition_blocking(a, b)
docstr_tok: ["Create","TF","RPC","client","to","connect","to","the","given","address",".","Args",":","rpc_layer",":","Communication","layer","between","client","and","server",".","Only","``","grpc","''","rpc","layer","is","supported","at","the","moment",".","address",":","Address","of","the","server","to","connect","the","RPC","client","to",".","name",":","Name","of","the","RPC","Client",".","You","can","create","multiple","clients","connecting","to","same","server","and","distinguish","them","using","different","names",".","timeout_in_ms",":","The","default","timeout","to","use","for","outgoing","RPCs","from","client",".","0","indicates","no","timeout",".","Exceeding","timeout","during","RPC","will","raise","DeadlineExceeded","error",".","Returns",":","An","instance","of","`","tf.distribute.experimental.rpc.Client","`","with","the","following","dynamically","added","methods","for","eagerly","created","clients",":","*","`","Registered","methods","`","e.g",".","multiply","(","*","*","args",")",":","If","Client","is","created","when","executing","eagerly",",","client","will","request","the","list","of","registered","methods","from","server","during","client","creation",".","The","convenience","methods","for","RPCs","will","be","dynamically","added","to","the","created","Client","instance",".","For","example",",","when","a","server","has","method","``","multiply","''","registered",",","the","client","object","created","in","eager","mode","will","have","'multiply","'","method","available",".","Users","can","use","client.multiply","(","..",")","to","make","RPC",",","instead","of","client.call","(","``","multiply","''",",","...",")","Both","``","call","''","and","``","multiply","''","methods","are","non-blocking","i.e",".","they","return","a","StatusOrResult","object","which","should","be","used","to","wait","for","getting","value","or","error",".","Along","with","the","above",",","blocking","versions","of","the","registered","methods","are","also","dynamically","added","to","client","instance",".","e.g",".","multiply_blocking","(","*","*","args",")",".","These","methods","block","till","the","RPC","is","finished","and","return","response","for","successful","RPC",".","Otherwise","raise","exception",".","These","methods","are","not","available","when","Client","is","created","inside","a","tf.function",".","Raises",":","A","ValueError","if","rpc_layer","other","than","``","grpc","''","is","used",".","Only","GRPC","is","supported","at","the","moment",".","A","DeadlineExceeded","exception","in","eager","mode","if","timeout","exceeds","while","creating","and","listing","client","methods",".","Example","usage",":",">",">",">","#","Have","server","already","started",".",">",">",">","import","portpicker",">",">",">","@","tf.function","(","input_signature=","[","...","tf.TensorSpec","(","[","]",",","tf.int32",")",",","...","tf.TensorSpec","(","[","]",",","tf.int32",")","]",")","...","def","remote_fn","(","a",",","b",")",":","...","return","tf.add","(","a",",","b",")",">",">",">","port","=","portpicker.pick_unused_port","(",")",">",">",">","address","=","``","localhost",":","{","}","''",".format","(","port",")",">",">",">","server","=","tf.distribute.experimental.rpc.Server.create","(","``","grpc","''",",","address",")",">",">",">","server.register","(","``","addition","''",",","remote_fn",")",">",">",">","server.start","(",")",">",">",">","#","Start","client",">",">",">","client","=","tf.distribute.experimental.rpc.Client.create","(","``","grpc","''",",","...","address=address",",","name=","''","test_client","''",")",">",">",">","a","=","tf.constant","(","2",",","dtype=tf.int32",")",">",">",">","b","=","tf.constant","(","3",",","dtype=tf.int32",")",">",">",">","result","=","client.call","(","...","args=","[","a",",","b","]",",","...","method_name=","''","addition","''",",","...","output_specs=tf.TensorSpec","(","(",")",",","tf.int32",")",")",">",">",">","if","result.is_ok","(",")",":","...","result.get_value","(",")",">",">",">","result","=","client.addition","(","a",",","b",")",">",">",">","if","result.is_ok","(",")",":","...","result.get_value","(",")",">",">",">","value","=","client.addition_blocking","(","a",",","b",")"]
code: def create(rpc_layer, address, name="", timeout_in_ms=0):
      """Create TF RPC client to connect to the given address.
  
      Args:
        rpc_layer: Communication layer between client and server. Only "grpc" rpc
          layer is supported at the moment.
        address: Address of the server to connect the RPC client to.
        name: Name of the RPC Client. You can create multiple clients connecting
          to same server and distinguish them using different names.
        timeout_in_ms: The default timeout to use for outgoing RPCs from client. 0
          indicates no timeout. Exceeding timeout during RPC will raise
          DeadlineExceeded error.
  
      Returns:
        An instance of `tf.distribute.experimental.rpc.Client` with the following
        dynamically added methods for eagerly created clients:
          * `Registered methods` e.g. multiply(**args):
              If Client is created when executing eagerly, client will request the
              list of registered methods from server during client creation.
              The convenience methods for RPCs will be dynamically added to the
              created Client instance.
  
              For example, when a server has method "multiply" registered, the
              client object created in eager mode will have 'multiply' method
              available. Users can use client.multiply(..) to make RPC, instead of
              client.call("multiply", ...)
  
              Both "call" and "multiply" methods are non-blocking i.e. they return
              a StatusOrResult object which should be used to wait for getting
              value or error.
  
              Along with the above, blocking versions of the registered
              methods are also dynamically added to client instance.
              e.g. multiply_blocking(**args). These methods block till the RPC is
              finished and return response for successful RPC. Otherwise raise
              exception.
  
              These methods are not available when Client is created inside a
              tf.function.
  
      Raises:
          A ValueError if rpc_layer other than "grpc" is used. Only GRPC
            is supported at the moment.
          A DeadlineExceeded exception in eager mode if timeout exceeds while
            creating and listing client methods.
  
      Example usage:
        >>> # Have server already started.
        >>> import portpicker
        >>> @tf.function(input_signature=[
        ...      tf.TensorSpec([], tf.int32),
        ...      tf.TensorSpec([], tf.int32)])
        ... def remote_fn(a, b):
        ...   return tf.add(a, b)
  
        >>> port = portpicker.pick_unused_port()
        >>> address = "localhost:{}".format(port)
        >>> server = tf.distribute.experimental.rpc.Server.create("grpc", address)
        >>> server.register("addition", remote_fn)
        >>> server.start()
  
        >>> # Start client
        >>> client = tf.distribute.experimental.rpc.Client.create("grpc",
        ...      address=address, name="test_client")
  
        >>> a = tf.constant(2, dtype=tf.int32)
        >>> b = tf.constant(3, dtype=tf.int32)
  
        >>> result = client.call(
        ...    args=[a, b],
        ...    method_name="addition",
        ...    output_specs=tf.TensorSpec((), tf.int32))
  
        >>> if result.is_ok():
        ...   result.get_value()
  
        >>> result = client.addition(a, b)
  
        >>> if result.is_ok():
        ...   result.get_value()
  
        >>> value = client.addition_blocking(a, b)
      """
      if rpc_layer != "grpc":
          raise ValueError(
              "Only GRPC backend is supported at the moment."
          )
      if context.executing_eagerly():
          list_registered_methods = True
      else:
          list_registered_methods = False
      return GrpcClient(
          address=address,
          name=name,
          list_registered_methods=list_registered_methods,
          timeout_in_ms=timeout_in_ms,
      )
  
imports: from typing import Optional, Sequence, Union
  import tensorflow.distribute.experimental.rpc.kernels.gen_rpc_ops
  from tensorflow.distribute.experimental.rpc.proto import tf_rpc_service_pb2
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.eager import function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import none_tensor
  from tensorflow.python.framework import type_spec
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.saved_model import nested_structure_coder
  from tensorflow.python.types import core
  from tensorflow.python.util import nest
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 1 for calling the Client obj's underlying member method code with example usage: obj.create(rpc_layer, address, name, timeout_in_ms) and returns: GrpcClient