Repository: tensorflow
Issue: api_compatibility_test fails on Python 3.11
Labels: stat:awaiting tensorflower,type:bug,type:build/install,comp:mkl,subtype: ubuntu/linux

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

Bug

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

Yes

### Source

source

### Tensorflow Version

git HEAD

### Custom Code

No

### OS Platform and Distribution

Ubuntu 20.04

### Mobile device

n/a

### Python version

3.9.16

### Bazel version

5.3.0

### GCC/Compiler version

10.2.1

### CUDA/cuDNN version

n/a

### GPU model and memory

n/a

### Current Behaviour?

//tensorflow/tools/api/tests:api_compatibility_test fails on Python 3.11
See https://github.com/tensorflow/tensorflow/actions/runs/5053005537/jobs/9066419128#step:6:5566

### Standalone code to reproduce the issue

```shell
bazel test --config=mkl_aarch64_threadpool --copt=-flax-vector-conversions --test_env=TF_ENABLE_ONEDNN_OPTS=1 --test_env=TF2_BEHAVIOR=1 --define=tf_api_version=2 --test_lang_filters=py --test_size_filters=small,medium --test_output=errors --verbose_failures=true --test_keep_going --notest_verbose_timeout_warnings --repo_env=PYTHON_BIN_PATH=/home/ubuntu/actions-runner/_work/tensorflow/tensorflow/bazel-ci_build-cache/.venv/tf/bin/python --build_tag_filters=-no_oss,-oss_excluded,-oss_serial,-v1only,-benchmark-test,-no_aarch64,-gpu,-tpu,-no_oss_py38,-no_oss_py39,-no_oss_py310 --test_tag_filters=-no_oss,-oss_excluded,-oss_serial,-v1only,-benchmark-test,-no_aarch64,-gpu,-tpu,-no_oss_py38,-no_oss_py39,-no_oss_py310 --local_test_jobs=64 --build_tests_only -- //tensorflow/... -//tensorflow/compiler/tf2tensorrt/... -//tensorflow/compiler/xrt/... -//tensorflow/core/tpu/... -//tensorflow/go/... -//tensorflow/java/... -//tensorflow/python/integration_testing/... -//tensorflow/tools/toolchains/... -//tensorflow/lite/... -//tensorflow/python/kernel_tests/nn_ops:atrous_conv2d_test -//tensorflow/python/kernel_tests/nn_ops:conv_ops_test -//tensorflow/compiler/mlir/tfr/examples/mnist:mnist_ops_test -//tensorflow/core/grappler/optimizers:auto_mixed_precision_test_cpu -//tensorflow/core/grappler/optimizers:remapper_test_cpu
```


### Relevant log output

```shell
Running tests under Python 3.11.3: /home/ubuntu/actions-runner/_work/tensorflow/tensorflow/bazel-ci_build-cache/.venv/tf/bin/python
[ RUN      ] ApiCompatibilityTest.testAPIBackwardsCompatibility
ERROR:tensorflow:TensorFlow API backwards compatibility test
This test ensures all changes to the public API of TensorFlow are intended.

If this test fails, it means a change has been made to the public API. Backwards
incompatible changes are not allowed. You can run the test as follows to update
test goldens and package them with your change.

    $ bazel run tensorflow/tools/api/tests:api_compatibility_test \
    #     -- --update_goldens True

You will need an API approval to make changes to the public TensorFlow API. This
includes additions to the API.

E0523 05:00:41.556244 281473269493776 api_compatibility_test.py:370] TensorFlow API backwards compatibility test
This test ensures all changes to the public API of TensorFlow are intended.

If this test fails, it means a change has been made to the public API. Backwards
incompatible changes are not allowed. You can run the test as follows to update
test goldens and package them with your change.

    $ bazel run tensorflow/tools/api/tests:api_compatibility_test \
    #     -- --update_goldens True

You will need an API approval to make changes to the public TensorFlow API. This
includes additions to the API.

ERROR:tensorflow:1 differences found between API and golden.
E0523 05:00:41.556445 281473269493776 api_compatibility_test.py:371] 1 differences found between API and golden.
ERROR:tensorflow:    Change detected in python object: tensorflow.train.
E0523 05:00:41.556506 281473269493776 api_compatibility_test.py:392]     Change detected in python object: tensorflow.train.
ERROR:tensorflow:    
  path: "tensorflow.train"
  tf_module {
    member {
      name: "BytesList"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "Checkpoint"
      mtype: "<type \'type\'>"
    }
    member {
      name: "CheckpointManager"
      mtype: "<type \'type\'>"
    }
    member {
      name: "CheckpointOptions"
      mtype: "<type \'type\'>"
    }
    member {
      name: "CheckpointView"
      mtype: "<type \'type\'>"
    }
    member {
      name: "ClusterDef"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "ClusterSpec"
      mtype: "<type \'type\'>"
    }
    member {
      name: "Coordinator"
      mtype: "<type \'type\'>"
    }
    member {
      name: "Example"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "ExponentialMovingAverage"
      mtype: "<type \'type\'>"
    }
    member {
      name: "Feature"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "FeatureList"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "FeatureLists"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "Features"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "FloatList"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "Int64List"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "JobDef"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "SequenceExample"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "ServerDef"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "TrackableView"
      mtype: "<type \'type\'>"
    }
    member {
      name: "experimental"
      mtype: "<type \'module\'>"
    }
    member_method {
      name: "checkpoints_iterator"
      argspec: "args=[\'checkpoint_dir\', \'min_interval_secs\', \'timeout\', \'timeout_fn\'], varargs=None, keywords=None, defaults=[\'0\', \'None\', \'None\'], "
    }
    member_method {
      name: "get_checkpoint_state"
      argspec: "args=[\'checkpoint_dir\', \'latest_filename\'], varargs=None, keywords=None, defaults=[\'None\'], "
    }
    member_method {
      name: "latest_checkpoint"
      argspec: "args=[\'checkpoint_dir\', \'latest_filename\'], varargs=None, keywords=None, defaults=[\'None\'], "
    }
    member_method {
      name: "list_variables"
      argspec: "args=[\'ckpt_dir_or_file\'], varargs=None, keywords=None, defaults=None"
    }
    member_method {
      name: "load_checkpoint"
      argspec: "args=[\'ckpt_dir_or_file\'], varargs=None, keywords=None, defaults=None"
    }
    member_method {
      name: "load_variable"
      argspec: "args=[\'ckpt_dir_or_file\', \'name\'], varargs=None, keywords=None, defaults=None"
    }
  }

E0523 05:00:41.556555 281473269493776 api_compatibility_test.py:393]     
  path: "tensorflow.train"
  tf_module {
    member {
      name: "BytesList"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "Checkpoint"
      mtype: "<type \'type\'>"
    }
    member {
      name: "CheckpointManager"
      mtype: "<type \'type\'>"
    }
    member {
      name: "CheckpointOptions"
      mtype: "<type \'type\'>"
    }
    member {
      name: "CheckpointView"
      mtype: "<type \'type\'>"
    }
    member {
      name: "ClusterDef"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "ClusterSpec"
      mtype: "<type \'type\'>"
    }
    member {
      name: "Coordinator"
      mtype: "<type \'type\'>"
    }
    member {
      name: "Example"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "ExponentialMovingAverage"
      mtype: "<type \'type\'>"
    }
    member {
      name: "Feature"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "FeatureList"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "FeatureLists"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "Features"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "FloatList"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "Int64List"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "JobDef"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "SequenceExample"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "ServerDef"
-     mtype: "<class \'google.protobuf.internal.python_message.GeneratedProtocolMessageType\'>"
?                                      ---------   ^^^
+     mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
?                                        ++ ^^^^
    }
    member {
      name: "TrackableView"
      mtype: "<type \'type\'>"
    }
    member {
      name: "experimental"
      mtype: "<type \'module\'>"
    }
    member_method {
      name: "checkpoints_iterator"
      argspec: "args=[\'checkpoint_dir\', \'min_interval_secs\', \'timeout\', \'timeout_fn\'], varargs=None, keywords=None, defaults=[\'0\', \'None\', \'None\'], "
    }
    member_method {
      name: "get_checkpoint_state"
      argspec: "args=[\'checkpoint_dir\', \'latest_filename\'], varargs=None, keywords=None, defaults=[\'None\'], "
    }
    member_method {
      name: "latest_checkpoint"
      argspec: "args=[\'checkpoint_dir\', \'latest_filename\'], varargs=None, keywords=None, defaults=[\'None\'], "
    }
    member_method {
      name: "list_variables"
      argspec: "args=[\'ckpt_dir_or_file\'], varargs=None, keywords=None, defaults=None"
    }
    member_method {
      name: "load_checkpoint"
      argspec: "args=[\'ckpt_dir_or_file\'], varargs=None, keywords=None, defaults=None"
    }
    member_method {
      name: "load_variable"
      argspec: "args=[\'ckpt_dir_or_file\', \'name\'], varargs=None, keywords=None, defaults=None"
    }
  }

[  FAILED  ] ApiCompatibilityTest.testAPIBackwardsCompatibility
INFO:tensorflow:time(__main__.ApiCompatibilityTest.testAPIBackwardsCompatibility): 2.5s
```
</details>