<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/ops/preprocess_ops_3d.py#L78-L123) |

Samples a single segment of size `num_steps` from a given sequence.

    tfm.vision.preprocess_ops_3d.sample_sequence(
        sequence: tf.Tensor,
        num_steps: int,
        random: bool,
        stride: int,
        seed: Optional[int] = None
    ) -> tf.Tensor

If `random` is not `True`, this function will simply sample the central window
of the sequence. Otherwise, a random offset will be chosen in a way that the
desired `num_steps` might be extracted from the sequence.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `sequence` | Any tensor where the first dimension is timesteps. |
| `num_steps` | Number of steps (e.g. frames) to take. |
| `random` | A boolean indicating whether to random sample the single window. If `True`, the offset is randomized. If `False`, the middle frame minus half of `num_steps` is the first frame. |
| `stride` | Distance to sample between timesteps. |
| `seed` | A deterministic seed to use when sampling. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A single [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) with first dimension `num_steps` with the sampled segment. ||

<br />