# tff.framework.RemoteExecutor

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

The remote executor is a local proxy for a remote executor instance.

    tff.framework.RemoteExecutor(
        stub: https://www.tensorflow.org/federated/api_docs/python/tff/framework/RemoteExecutorStub,
        dispose_batch_size=20,
        stream_structs: bool = False
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `stub` | An instance of stub used for communication with the remote executor service. |
| `dispose_batch_size` | The batch size for requests to dispose of remote worker values. Lower values will result in more requests to the remote worker, but will result in values being cleaned up sooner and therefore may result in lower memory usage on the remote worker. |
| `stream_structs` | The flag to enable decomposing and streaming struct values. |

<br />

## Methods

### `close`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    close()

Release resources associated with this Executor, if any.

If the executor has one or more target Executors, implementation of this
method must close them.

### `create_call`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    create_call(
        comp, arg=None
    )

A coroutine that creates a call to `comp` with optional argument `arg`.

<br />

<br />

<br />

| Args ||
|---|---|
| `comp` | The computation to invoke. It must have been first embedded in the executor by calling `create_value()` on it first. |
| `arg` | An optional argument of the call, or `None` if no argument was supplied. If it is present, it must have been embedded in the executor by calling `create_value()` on it first. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An instance of `ExecutorValue` that represents the constructed call. ||

<br />

### `create_selection`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    create_selection(
        source, index
    )

A coroutine that creates a selection from `source`.

<br />

<br />

<br />

| Args ||
|---|---|
| `source` | The source to select from. The source must have been embedded in this executor by invoking `create_value()` on it first. |
| `index` | An integer index to select. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An instance of `ExecutorValue` that represents the constructed selection. ||

<br />

### `create_struct`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    create_struct(
        elements
    )

A coroutine that creates a tuple of `elements`.

<br />

<br />

<br />

| Args ||
|---|---|
| `elements` | A collection of `ExecutorValue`s to create a tuple from. The collection may be of any kind accepted by [`structure.from_container`](https://www.tensorflow.org/federated/api_docs/python/tff/structure/from_container), including dictionaries and lists. The `ExecutorValues` in the container must have been created by calling `create_value` on this executor. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An instance of `ExecutorValue` that represents the constructed tuple. ||

<br />

### `create_value`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    create_value(
        value, type_spec=None
    )

A coroutine that creates embedded value from `value` of type `type_spec`.

This function is used to embed a value within the executor. The argument
can be one of the plain Python types, a nested structure, a representation
of a TFF computation, etc. Once embedded, the value can be further passed
around within the executor. For functional values, embedding them prior to
invocation potentially allows the executor to amortize overhead across
multiple calls.

<br />

<br />

<br />

| Args ||
|---|---|
| `value` | An object that represents the value to embed within the executor. |
| `type_spec` | An optional [`tff.Type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/Type) of the value represented by this object, or something convertible to it. The type can only be omitted if the value is a instance of [`tff.TypedObject`](https://www.tensorflow.org/federated/api_docs/python/tff/TypedObject). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An instance of `ExecutorValue` that represents the embedded value. ||

<br />

### `create_value_stream_structs`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    create_value_stream_structs(
        value, type_spec
    )

### `set_cardinalities`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    set_cardinalities(
        cardinalities: Mapping[https://www.tensorflow.org/federated/api_docs/python/tff/framework/PlacementLiteral, int]
    )