<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/trainers/data_adapters/data_adapter_utils.py#L11-L51) |

Unpacks user-provided data tuple.

    tf.keras.utils.unpack_x_y_sample_weight(
        data
    )

### Used in the notebooks

| Used in the guide |
|---|
| - [Integrating MinDiff without MinDiffModel](https://www.tensorflow.org/responsible_ai/model_remediation/min_diff/guide/integrating_min_diff_without_min_diff_model) - [Creating a custom Counterfactual Logit Pairing Dataset](https://www.tensorflow.org/responsible_ai/model_remediation/counterfactual/guide/creating_a_custom_counterfactual_dataset) |

This is a convenience utility to be used when overriding
[`Model.train_step`](https://www.tensorflow.org/api_docs/python/tf/keras/Model#train_step), [`Model.test_step`](https://www.tensorflow.org/api_docs/python/tf/keras/Model#test_step), or [`Model.predict_step`](https://www.tensorflow.org/api_docs/python/tf/keras/Model#predict_step).
This utility makes it easy to support data of the form `(x,)`,
`(x, y)`, or `(x, y, sample_weight)`.

#### Example:

    features_batch = ops.ones((10, 5))
    labels_batch = ops.zeros((10, 5))
    data = (features_batch, labels_batch)
    # `y` and `sample_weight` will default to `None` if not provided.
    x, y, sample_weight = unpack_x_y_sample_weight(data)
    sample_weight is None
    True

<br />

<br />

<br />

| ## Args ||
|---|---|
| `data` | A tuple of the form `(x,)`, `(x, y)`, or `(x, y, sample_weight)`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The unpacked tuple, with `None`s for `y` and `sample_weight` if they are not provided. ||

<br />