# tf_agents.utils.example_encoding.get_example_decoder

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/utils/example_encoding.py#L117-L178) |

Get an example decoder function for a nested spec.

    tf_agents.utils.example_encoding.get_example_decoder(
        example_spec, batched=False, compress_image=False
    )

Given a spec, returns an example decoder function. The decoder function parses
string serialized example protos into tensors according to the given spec.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `example_spec` | list/tuple/nest of ArraySpecs describing a single example. |
| `batched` | Boolean indicating if the decoder will receive batches of serialized data. |
| `compress_image` | Whether to decompress image. It is assumed that any uint8 tensor of rank 3 with shape (w,h,c) is an image. If the tensor was compressed in the encoder, it needs to be decompressed. |

<br />

<br />

| ## Returns ||
|---|---|
| Function <br /> </td> </tr> <tr> <td> `decoder`<a id="decoder"></a> </td> <td> `serialized_proto` tf.tensor[string]) -> example_spec nest of tensors <br /> ||

<br />