<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/ops/numpy.py#L4266-L4304) |

Test whether each element of `x1` is present in `x2`.

#### View aliases


**Main aliases**

[`tf.keras.ops.numpy.isin`](https://www.tensorflow.org/api_docs/python/tf/keras/ops/isin)

<br />

    tf.keras.ops.isin(
        x1, x2, assume_unique=False, invert=False
    )

This operation performs element-wise checks to determine if each value
in `x1` is contained within `x2`. The result is a boolean tensor with
the same shape as `x1`, where each entry is `True` if the corresponding
element in `x1` is in `x2`, and `False` otherwise.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x1` | Input tensor or array-like structure to test. |
| `x2` | Values against which each element of `x1` is tested. Can be a tensor, list, or scalar. |
| `assume_unique` | Boolean (default: False). If True, assumes both `x1` and `x2` contain only unique elements. This can speed up the computation. If False, duplicates will be handled correctly but may impact performance. |
| `invert` | A boolean (default: False). If True, inverts the result. Entries will be `True` where `x1` elements are not in `x2`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A boolean tensor of the same shape as `x1` indicating element-wise membership in `x2`. ||

<br />

#### Example:

    from keras import ops
    x1 = ops.array([0, 1, 2, 5])
    x2 = ops.array([0, 2])
    result = ops.isin(x1, x2)
    array([ True, False,  True, False])