How to solve this issue - ImportError: cannot import name 'estimator' from 'tensorflow.compat.v1' (/root/.local/lib/python3.10/site-packages/tensorflow/_api/v2/compat/v1/__init__.py)
Tried reinstalling tensorflow-estimator but still results are same. @Rajcr2,
Could you please provide the standalone code to reproduce the issue which helps to debug the same. Thank you! Getting the same error when using TensorFlow ^2.15.0 and tensorflow-hub ^0.15.0 on a Mlflow Docker container with Python 3.10
```bash
    from tensorflow_hub import load
  File "/usr/local/lib/python3.10/site-packages/tensorflow_hub/__init__.py", line 90, in <module>
    from tensorflow_hub.estimator import LatestModuleExporter
  File "/usr/local/lib/python3.10/site-packages/tensorflow_hub/estimator.py", line 21, in <module>
    from tensorflow.compat.v1 import estimator as tf_estimator
ImportError: cannot import name 'estimator' from 'tensorflow.compat.v1' (/usr/local/lib/python3.10/site-packages/tensorflow/_api/v2/compat/v1/__init__.py)
``` @amrabed,
Could you please try to create the new issue from [here](https://github.com/tensorflow/tensorflow/issues/new/choose) providing the complete standalone code which helps to debug the issue. 
Thank you! For my case, it was incompatible versions of TF and TF-hub. TF got upgraded to `2.16.1`, while TF-hub stayed at `0.15.0`. I fixed the issue by pinning my TF version to `2.16.1` and TF-hub version to `0.16.1`

Here is the code I used for your reference:
```python
from tensorflow_hub import load  # this line caused the error before
encode = load("https://tfhub.dev/google/universal-sentence-encoder/4")
encode(["whatever"])
```
I hope that helps you or the OP
 This solution worked for me!

Recently, Google Colab updated its TensorFlow version from 2.15.0 to 2.16.1. Try reinstalling TensorFlow using the following commands:

`!pip uninstall tensorflow --y`
`!pip install tensorflow==2.15.0`

then restart runtime when asked in colab. You should be able to import the correct version of TensorFlow. @amrabed
For the tensorflow v2.15, you can directly run the command from tensorflow_hub import load for the tf-hub. But whereas for the latest stable tensorflow v2.16.1, please try to run **pip install tensorflow-hub** for the tensorflow-hub 0.16.1. 
https://pypi.org/project/tensorflow-hub/#description
I tried to execute and was able to import. Kindly find the gist of it [here](https://colab.research.google.com/gist/tilakrayal/923b68ffec7b9bf23d8c347a9aaa4d6c/untitled1767.ipynb).

Also there is an open issue in the tensorflow/tf-hub repo for the same issue. https://github.com/tensorflow/hub/issues/901

Thank you! This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. 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/63618">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/63618">No</a>
 I fixed the issue by changing my TF version to 2.16.1 and TF-hub version to 0.16.1
### Issue type

Bug

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

Yes

### Source

source

### TensorFlow version

2.15.0

### Custom code

Yes

### OS platform and distribution

_No response_

### Mobile device

_No response_

### Python version

_No response_

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

How to solve this issue - ImportError: cannot import name 'estimator' from 'tensorflow.compat.v1' (/root/.local/lib/python3.10/site-packages/tensorflow/_api/v2/compat/v1/__init__.py)

anyone ?

### Standalone code to reproduce the issue

```shell
2024-03-13 14:13:23.953994: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-03-13 14:13:25.304466: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Traceback (most recent call last):
  File "/content/drive/MyDrive/tf_CrimeDetection/workspace/CCTV_New/model_main_tf2.py", line 31, in <module>
    from object_detection import model_lib_v2
  File "/usr/local/lib/python3.10/dist-packages/object_detection/model_lib_v2.py", line 30, in <module>
    from object_detection import inputs
  File "/usr/local/lib/python3.10/dist-packages/object_detection/inputs.py", line 24, in <module>
    from tensorflow.compat.v1 import estimator as tf_estimator
ImportError: cannot import name 'estimator' from 'tensorflow.compat.v1' (/root/.local/lib/python3.10/site-packages/tensorflow/_api/v2/compat/v1/__init__.py)
```


### Relevant log output

_No response_