Reducing tensorflowlite_flex shared library with tflite models
Hi @aflaischer, using a non-existent model I got a similar size:

```
-r-xr-xr-x 1 xxxxxxxx xxxxxxxxxxx 185M Dec  5 22:24 libtensorflowlite_flex.so*
```

It's possible if no legitimate models are listed it just builds all the flex ops, is it possible for you to share your reference_model.tflite file? Hello @pkgoogle 

Sure no problem, here is the reference_model.tflite
I put it in a zip file as the tflite extension is not supported as an attachment type.

[reference_model.zip](https://github.com/tensorflow/tensorflow/files/13579556/reference_model.zip)
 Hi @aflaischer, thanks for that ... interestingly if I do it with the reference_model it does reduce the size by 2 MB, but that doesn't quite seem right

```
-r-xr-xr-x 1 xxxxxxx xxxxxxxxxx 183M Dec  6 19:21 libtensorflowlite_flex.so*
```

I looked into the actual build definition: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/delegates/flex/build_def.bzl#L114 It is taking the models into account ... 

It is using this binary to list out the flex ops: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/delegates/flex/build_def.bzl#L55

So i tried it manually with your reference file:

```
./list_flex_ops_main --graphs=reference_model.tflite
[["BroadcastGradientArgs","BCastGradArgsOp<int32>"],["ReluGrad","ReluGradOp<CPUDevice, float>"],["Restore","RestoreOp"],["Save","SaveOp"]]
```

Not sure why having 4 flex ops would end up reducing the size of the built .so.

@terryheo can you please take a look? Thanks. hello @pkgoogle @terryheo 
do you have some feedback on this topic?

Thanks
### Issue type

Build/Install

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

No

### Source

source

### TensorFlow version

tf2.15

### Custom code

Yes

### OS platform and distribution

Linux Ubuntu 20.04.6 LTS

### Mobile device

_No response_

### Python version

Python 3.10.13

### Bazel version

bazel 6.1.0

### GCC/compiler version

Ubuntu clang version 17.0.4 

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

Hello,

I tried to follow the following documentation to reduce the size of the tensorflowlite_flex shared library:
https://www.tensorflow.org/lite/guide/reduce_binary_size#advanced_usages_build_custom_cc_shared_libraries

So I have made my custom BUILD file with the list of my models:
```
load(
    "@org_tensorflow//tensorflow/lite/delegates/flex:build_def.bzl",
    "tflite_flex_shared_library"
)

# Shared lib target for convenience, pulls in the standard set of TensorFlow
# ops and kernels. The output library name is platform dependent:
#   - Linux/Android: `libtensorflowlite_flex.so`
#   - Mac: `libtensorflowlite_flex.dylib`
#   - Windows: `libtensorflowlite_flex.dll`
tflite_flex_shared_library(
  name = "tensorflowlite_flex",
  models = [":reference_model.tflite"]
)
```

with tmp created in the root of Tensorflow source repository;
```
tf-docker /tmp/tensorflow > ll tmp/
total 36
-rw-r--r-- 1 root root  1861 Nov 23 15:00 BUILD
-rw-r--r-- 1 root root 28152 Nov 23 15:00 reference_model.tflite
```

the compilation is working but I ended up with this size for the tensorflowlite_flex:
```
tf-docker /tmp/tensorflow > bazel build -c opt --cxxopt='--std=c++17' --copt=-Wno-gnu-offsetof-extensions --config=monolithic --host_crosstool_top=@bazel_tools//tools/cpp:toolchain //tmp:tensorflowlite_flex
tf-docker /tmp/tensorflow > ll -h bazel-bin/tmp/libtensorflowlite_flex.so
-r-xr-xr-x 1 root root 184M Nov 23 16:05 bazel-bin/tmp/libtensorflowlite_flex.so
```


While without using a custom BUILD file:
```
tf-docker /tmp/tensorflow > bazel build -c opt --cxxopt='--std=c++17' --copt=-Wno-gnu-offsetof-extensions --config=monolithic tensorflow/lite/delegates/flex:tensorflowlite_flex
tf-docker /tmp/tensorflow > ll -h bazel-bin/tensorflow/lite/delegates/flex/libtensorflowlite_flex.so
-r-xr-xr-x 1 root root 184M Nov 23 16:45 bazel-bin/tensorflow/lite/delegates/flex/libtensorflowlite_flex.so
```


I ended up with the same size.


I even made a test with an none existing model:
`  models = [":model_not_existing.tflite"]`

and I get no error but the same size as well.

so it is like the model I pass is not taken into account at all.

Do you know where the issue could come from?

### Standalone code to reproduce the issue

```shell
docker run -it -w /tmp  tensorflow/build:2.16-python3.10

git clone --depth 1  --branch r2.15  https://github.com/tensorflow/tensorflow.git
cd tensorflow
./configure
mkdir -p tmp && touch tmp/BUILD
vi tmp/BUILD # add content from above for BUILD file

bazel build -c opt --cxxopt='--std=c++17' --copt=-Wno-gnu-offsetof-extensions --config=monolithic --host_crosstool_top=@bazel_tools//tools/cpp:toolchain //tmp:tensorflowlite_flex

ll -h bazel-bin/tmp/libtensorflowlite_flex.so
```


### Relevant log output

```shell
-r-xr-xr-x 1 root root 184M Nov 23 16:05 bazel-bin/tmp/libtensorflowlite_flex.so
```
