Unable to hide TPUs
@AakashKumarNain Please follow [this](https://www.tensorflow.org/guide/tpu) guide to know more about the usability of TPU using TF. I tried to replicate the issue as mentioned above, and didn't face the error reported. I was able to run the code as expected. Could you please have a look at this [gist](https://colab.research.google.com/gist/sushreebarsa/07e0472488f87c20c3a943e9b9a10946/61293.ipynb#scrollTo=bvzFrxESe2Wh) and confirm the same. In case you are using multiple TPUs you can also detect the [TPUs](https://colab.research.google.com/notebooks/tpu.ipynb#scrollTo=FpvUOuC3j27n) as below;

```
import tensorflow as tf
print("Tensorflow version " + tf.__version__)

try:
  tpu = tf.distribute.cluster_resolver.TPUClusterResolver()  # TPU detection
  print('Running on TPU ', tpu.cluster_spec().as_dict()['worker'])
except ValueError:
  raise BaseException('ERROR: Not connected to a TPU runtime; please see the previous cell in this notebook for instructions!')

tf.config.experimental_connect_to_cluster(tpu)
tf.tpu.experimental.initialize_tpu_system(tpu)
tpu_strategy = tf.distribute.TPUStrategy(tpu)


```
 Thank you! @sushreebarsa I am not asking `How to use TPUs with TF?`. I have different problem on hand. I have a TPU cluster but I don't want TF to use it. I don't want TF to use any of the TPUs for processing. I want to hide the TPUs and move everything to CPU only. Please go through the issue again for the details @AakashKumarNain Sorry for the misread. 
@sachinprasadhs Could you please have a look at this issue. Thank you! @sachinprasadhs any suggestions? `tf.config.set_visible_devices`  `device_type` works for `CPU` or `GPU`, other devices will be left [unaltered](https://www.tensorflow.org/api_docs/python/tf/config/set_visible_devices#args).

For TPUs, you need to configure the logical devices as something like below.

```
logical_devices = tf.config.list_logical_devices('TPU')
for logical_device in logical_devices:
    tf.config.set_logical_device_configuration(
        logical_device,
        [tf.config.LogicalDeviceConfiguration(), ]
    )
``` Thanks for the answer but this doesn't work. Error below

```
ValueError: Unrecognized device: LogicalDevice(name='/device:TPU:0', device_type='TPU')
``` Could you please attach the outcome of `tf.config.list_logical_devices()` I have already done that in the code snippet at the top Any updates on this? Team is currently looking into this.
Meantime, can you please check by calling `context._reset_context()` to remove the TPUs from the logical device list. 
### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

binary

### TensorFlow version

2.12

### Custom code

No

### OS platform and distribution

Kaggle Notebooks

### 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 behavior?

Unable to hide TPUs from TensorFlow. The consequence of this is that if we want to use JAX along with TensorFlow, only one of them will be able to initialize the TPU system, and the other will fail. We won't be able to use `tfds`, `tf.image` or any TF operation per se if we can't hide TPUs from being used by TF. I want all these operations to run on CPU only, and leverage JAX for TPU. Here is the code to test it on a TPU machine:

```python
import tenorflow as tf

tf.config.set_visible_devices([], device_type="TPU_SYSTEM")
tf.config.set_visible_devices([], device_type="TPU")

print(tf.config.list_logical_devices())

# output:
# [LogicalDevice(name='/device:CPU:0', device_type='CPU'),
#  LogicalDevice(name='/device:TPU_SYSTEM:0', device_type='TPU_SYSTEM'),
#  LogicalDevice(name='/device:TPU:0', device_type='TPU'),
#  LogicalDevice(name='/device:TPU:1', device_type='TPU'),
#  LogicalDevice(name='/device:TPU:2', device_type='TPU'),
#  LogicalDevice(name='/device:TPU:3', device_type='TPU'),
#  LogicalDevice(name='/device:TPU:4', device_type='TPU'),
#  LogicalDevice(name='/device:TPU:5', device_type='TPU'),
#  LogicalDevice(name='/device:TPU:6', device_type='TPU'),
# LogicalDevice(name='/device:TPU:7', device_type='TPU')]
```

This also doesn't work:

```python
physical_devices = tf.config.list_physical_devices()
tf.config.set_visible_devices(physical_devices[0], 'CPU')
```

### Standalone code to reproduce the issue

```shell
import tenorflow as tf

tf.config.set_visible_devices([], device_type="TPU_SYSTEM")
tf.config.set_visible_devices([], device_type="TPU")

print(tf.config.list_logical_devices())

# This also doesn't work:
physical_devices = tf.config.list_physical_devices()
tf.config.set_visible_devices(physical_devices[0], 'CPU')



### Relevant log output

_No response_