why my code can run in tensorflow-gpu,can`t run in tensorflow-cpu?
Hi, thanks for taking the time to report the issue.

Tensorflow's gather op has inconsistent behavior: On GPU it silently returns zeros (for speed), on CPU it checks the bounds fails if the bounds are exceded. 

See the wraning here:  

https://www.tensorflow.org/api_docs/python/tf/gather#validate_indices


 Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59750">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59750">No</a>

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

Yes

### Source

source

### Tensorflow Version

2.6

### Custom Code

Yes

### OS Platform and Distribution

windows10

### Mobile device

_No response_

### Python version

3.8

### Bazel version

_No response_

### GCC/Compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current Behaviour?

```shell
my code can run in tensorflow-gpu==2.6.0,but can`t run in tensorflow-cpu==2.6.0. they use same code and DS .why?
error is :
Traceback (most recent call last):
  File "C:\Users\DH\PycharmProjects\four\model_test.py", line 53, in <module>
    movie_combine_layer_flat_val = movie_layer_model([np.reshape(item.take(0), [1, 1]), titles, actors, categories])
  File "C:\Users\DH\anaconda3\envs\test\lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "C:\Users\DH\AppData\Roaming\Python\Python39\site-packages\tensorflow\python\framework\ops.py", line 7215, in raise_from_not_ok_status
    raise core._status_to_exception(e) from None  # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: Exception encountered when calling layer "movie_actor_embed_layer" "                 f"(type Embedding).

{{function_node __wrapped__ResourceGather_device_/job:localhost/replica:0/task:0/device:CPU:0}} indices[0,3] = 2010 is not in [0, 2006) [Op:ResourceGather]

Call arguments received by layer "movie_actor_embed_layer" "                 f"(type Embedding):
  • inputs=tf.Tensor(shape=(1, 30), dtype=int32)
it look like matrix boundary problem, but it can`t happen in tensorflow-gpu-2.6.0
```


### Standalone code to reproduce the issue

```shell
for item in movies.values:
    titles = np.zeros([1, title_count])
    titles[0] = item.take(1)

    actors = np.zeros([1, 30])
    actors[0] = item.take(2)

    categories = np.zeros([1, 10])
    categories[0] = item.take(3)

    movie_combine_layer_flat_val = movie_layer_model([np.reshape(item.take(0), [1, 1]), titles, actors, categories])
    movie_matrics.append(movie_combine_layer_flat_val)
```


### Relevant log output

```shell
Traceback (most recent call last):
  File "C:\Users\DH\PycharmProjects\four\model_test.py", line 53, in <module>
    movie_combine_layer_flat_val = movie_layer_model([np.reshape(item.take(0), [1, 1]), titles, actors, categories])
  File "C:\Users\DH\anaconda3\envs\test\lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "C:\Users\DH\AppData\Roaming\Python\Python39\site-packages\tensorflow\python\framework\ops.py", line 7215, in raise_from_not_ok_status
    raise core._status_to_exception(e) from None  # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: Exception encountered when calling layer "movie_actor_embed_layer" "                 f"(type Embedding).

{{function_node __wrapped__ResourceGather_device_/job:localhost/replica:0/task:0/device:CPU:0}} indices[0,3] = 2010 is not in [0, 2006) [Op:ResourceGather]

Call arguments received by layer "movie_actor_embed_layer" "                 f"(type Embedding):
  • inputs=tf.Tensor(shape=(1, 30), dtype=int32)
```
</details>