# tf_agents.trajectories.time_step_spec

<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/trajectories/time_step.py#L415-L466) |

Returns a `TimeStep` spec given the observation_spec.

#### View aliases


**Main aliases**

[`tf_agents.trajectories.time_step.time_step_spec`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/time_step_spec)

<br />

    tf_agents.trajectories.time_step_spec(
        observation_spec: Optional[types.NestedSpec] = None,
        reward_spec: Optional[types.NestedSpec] = None
    ) -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/TimeStep

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Policies](https://www.tensorflow.org/agents/tutorials/3_policies_tutorial) - [Tutorial on Multi Armed Bandits in TF-Agents](https://www.tensorflow.org/agents/tutorials/bandits_tutorial) - [A Tutorial on Multi-Armed Bandits with Per-Arm Features](https://www.tensorflow.org/agents/tutorials/per_arm_bandits_tutorial) |

<br />

<br />

<br />

| ## Args ||
|---|---|
| `observation_spec` | A nest of [`tf.TypeSpec`](https://www.tensorflow.org/api_docs/python/tf/TypeSpec) or `ArraySpec` objects. |
| `reward_spec` | (Optional) A nest of [`tf.TypeSpec`](https://www.tensorflow.org/api_docs/python/tf/TypeSpec) or `ArraySpec` objects. Default - a scalar float32 of the same type (Tensor or Array) as `observation_spec`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `TimeStep` with the same types (`TypeSpec` or `ArraySpec`) as the first entry in `observation_spec`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If observation and reward specs aren't both either tensor type specs or array type specs. |

<br />