# tf.data.experimental.service.CrossTrainerCache

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/data/experimental/ops/data_service_ops.py#L117-L155) |

Options related to the tf.data service cross trainer cache.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.data.experimental.service.CrossTrainerCache`](https://www.tensorflow.org/api_docs/python/tf/data/experimental/service/CrossTrainerCache)

<br />

    tf.data.experimental.service.CrossTrainerCache(
        trainer_id
    )

This is used to enable cross-trainer cache when distributing a dataset. For
example:

    dataset = dataset.apply(tf.data.experimental.service.distribute(
        processing_mode=tf.data.experimental.service.ShardingPolicy.OFF,
        service=FLAGS.tf_data_service_address,
        job_name="job",
        cross_trainer_cache=data_service_ops.CrossTrainerCache(
            trainer_id=trainer_id())))

For more details, refer to
<https://www.tensorflow.org/api_docs/python/tf/data/experimental/service#sharing_tfdata_service_with_concurrent_trainers>

<br />

<br />

<br />

| ## Args ||
|---|---|
| `trainer_id` | Each training job has a unique ID. Once a job has consumed data, the data remains in the cache and is re-used by jobs with different `trainer_id`s. Requests with the same `trainer_id` do not re-use data. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| ValueError if `trainer_id` is empty. ||

<br />