The inference result of converted TFLite model is wrong on mobile
I run the tf.lite.experimental.Analyzer, and the TensorFlow Lite model result as below for your reference:
```bash
---------------------------------------------------------------
Your TFLite model has '1' signature_def(s).

Signature#0 key: 'serving_default'
- Subgraph: Subgraph#0
- Inputs: 
    'arg_0' : T#0
- Outputs: 
    '797' : T#801

---------------------------------------------------------------
              Model size:   66529376 bytes
    Non-data buffer size:     104044 bytes (00.16 %)
  Total data buffer size:   66425332 bytes (99.84 %)
    (Zero value buffers):      21280 bytes (00.03 %)

* Buffers of TFLite model are mostly used for constant tensors.
  And zero value buffers are buffers filled with zeros.
  Non-data buffers area are used to store operators, subgraphs and etc.
  You can find more details from https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/schema/schema.fbs
``` I found that the input shape (1, 3,256,256) in TensorFlow Lite is different from the MiDaS provided model (1,256,256,3)

I use the 'onnx2tf' that it automatically transposes (N,C,H,W) to (N,H,W,C) So I will close this issue.
### 1. System information

- OS Platform and Distribution: iOS / Android

### 2. Code

I download the [MiDaS ONNX model](https://github.com/isl-org/MiDaS/releases/download/v2_1/model-small.onnx) and then run below python codes:

1. I fix the onnx model's key problem ( the model input tensor name = '0' ==> KeyError: '0')
```python
import onnx
from onnx import helper

onnx_model_path = "model-small.onnx"
onnx_model = onnx.load(onnx_model_path)

# Define a mapping from old names to new names
name_map = {"0": "arg_0"}

# Initialize a list to hold the new inputs
new_inputs = []

# Iterate over the inputs and change their names if needed
for inp in onnx_model.graph.input:
    if inp.name in name_map:
        # Create a new ValueInfoProto with the new name
        new_inp = helper.make_tensor_value_info(name_map[inp.name],
                                                inp.type.tensor_type.elem_type,
                                                [dim.dim_value for dim in inp.type.tensor_type.shape.dim])
        new_inputs.append(new_inp)
    else:
        new_inputs.append(inp)

# Clear the old inputs and add the new ones
onnx_model.graph.ClearField("input")
onnx_model.graph.input.extend(new_inputs)

# Go through all nodes in the model and replace the old input name with the new one
for node in onnx_model.graph.node:
    for i, input_name in enumerate(node.input):
        if input_name in name_map:
            node.input[i] = name_map[input_name]

# Save the renamed ONNX model
onnx_model_path = "model-small-fix.onnx"
onnx.save(onnx_model, onnx_model_path)
```

2. Convert it into TensorFlow saved model format (the result of the TF model is confirmed OK):

```python
import onnx
from onnx_tf.backend import prepare

model_path = "model-small-fix.onnx"
output_path = "modified_model_2"

onnx_model = onnx.load(model_path) # load onnx model
tf_rep = prepare(onnx_model)  # prepare tf representation
tf_rep.export_graph(output_path)  # export the model
```

3. Convert the TensorFlow saved model into TFLite:

```python

import tensorflow as tf
import io

path = 'modified_model_2'
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir=path)
tf_lite_model = converter.convert()
open('model_1.tflite', 'wb').write(tf_lite_model)
```


4. Evaluate in python

```python

import tensorflow as tf
import cv2
import numpy as np
import os

input_image_path = "input/COCO_val2014_000000000761.jpg"
tflite_model_path = "/model_fp16-3.tflite"

interpreter = tf.lite.Interpreter(model_path=tflite_model_path)
interpreter.allocate_tensors()

input_details = interpreter.get_input_details()
input_index = interpreter.get_input_details()[0]['index']
output_index = interpreter.get_output_details()[0]['index']

# read image
input_image = cv2.imread(input_image_path)
org_shape = input_image.shape

input_image = cv2.resize(input_image, (256, 256))
input_image = cv2.cvtColor(input_image, cv2.COLOR_BGR2RGB)
input_image = input_image.astype(np.float32) / 255.0
input_image = np.expand_dims(input_image, axis=0)
input_image = np.transpose(input_image, [0, 3, 1, 2]) 
interpreter.set_tensor(input_index, input_image)

# get result
interpreter.invoke()
output_image = interpreter.get_tensor(output_index)
output_image = output_image[0, :, :]  # remove channel

normalized_output = (output_image - np.min(output_image)) / (np.max(output_image) - np.min(output_image))
normalized_output = (normalized_output * 255).astype(np.uint8)
normalized_output = cv2.resize(normalized_output, (org_shape[1], org_shape[0]))  

# get file name
file_name = os.path.basename(input_image_path)
output_file_name = f"output/{file_name}"

# write image
cv2.imwrite(output_file_name, normalized_output)
print(f"file {file_name} copy to {output_file_name} ")

```

5. Replace the model in iOS project (model_opt.tflite) and run on iOS, the code is unchanged from [MiDaS iOS](https://github.com/isl-org/MiDaS/tree/master/mobile/ios)

```swift
private func inference(from data: Data) {
  // Copy the initialized `Data` to the input `Tensor`.
  do {
    try interpreter.copy(data, toInputAt: 0)

    // Run inference by invoking the `Interpreter`.
    try interpreter.invoke()

    // Get the output `Tensor` to process the inference results.
    outputTensor = try interpreter.output(at: 0)

  } catch let error {
    os_log(
      "Failed to invoke the interpreter with error: %s", type: .error,
      error.localizedDescription)
    return
  }
}
```

### 3. Failure after conversion
The Model runs in **iOS** with wrong result:
![COCO_val2014_000000000761_CPU_1](https://github.com/tensorflow/tensorflow/assets/15173100/1e90ad49-dddf-45f4-b69c-b949be4f3c56)

The Model runs in **Python** with correct result:
![COCO_val2014_000000000761](https://github.com/tensorflow/tensorflow/assets/15173100/58639abc-fdac-4240-819b-16972bda35e7)


The right result from TensorFlow model during above conversion:
![COCO_val2014_000000000761](https://github.com/tensorflow/tensorflow/assets/15173100/48360bec-2d17-459f-8ece-6d5523dd18c6)

The original input:
![COCO_val2014_000000000761](https://github.com/tensorflow/tensorflow/assets/15173100/b8f5eef4-72eb-4d56-9f67-d622c0fc0101)


### 5. (optional) Any other info / logs

The log when converting from TensorFlow to TensorFlow Lite:
 
```bash
python convert_tf2tflite_savedmodel.py 
2024-01-10 14:26:37.071501: W tensorflow/compiler/mlir/lite/python/tf_tfl_flatbuffer_helpers.cc:378] Ignored output_format.
2024-01-10 14:26:37.071524: W tensorflow/compiler/mlir/lite/python/tf_tfl_flatbuffer_helpers.cc:381] Ignored drop_control_dependency.
2024-01-10 14:26:37.072913: I tensorflow/cc/saved_model/reader.cc:83] Reading SavedModel from: /modified_model_2
2024-01-10 14:26:37.089615: I tensorflow/cc/saved_model/reader.cc:51] Reading meta graph with tags { serve }
2024-01-10 14:26:37.089642: I tensorflow/cc/saved_model/reader.cc:146] Reading SavedModel debug info (if present) from: /modified_model_2
2024-01-10 14:26:37.110969: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:388] MLIR V1 optimization pass is not enabled
2024-01-10 14:26:37.118290: I tensorflow/cc/saved_model/loader.cc:233] Restoring SavedModel bundle.
2024-01-10 14:26:37.263435: I tensorflow/cc/saved_model/loader.cc:217] Running initialization op on SavedModel bundle at path: /modified_model_2
2024-01-10 14:26:37.389643: I tensorflow/cc/saved_model/loader.cc:316] SavedModel load for tags { serve }; Status: success: OK. Took 316731 microseconds.
2024-01-10 14:26:37.545668: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:269] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable.
Summary on the non-converted ops:
---------------------------------
 * Accepted dialects: tfl, builtin, func
 * Non-Converted Ops: 293, Total Ops 804, % non-converted = 36.44 %
 * 293 ARITH ops

- arith.constant:  293 occurrences  (f32: 281, i32: 12)



  (f32: 99)
  (f32: 73)
  (f32: 24)
  (f32: 73)
  (f32: 45)
  (f32: 7)
  (f32: 1)
  (f32: 5)
  (f32: 1)
  (f32: 180)
2024-01-10 14:26:38.047603: I tensorflow/compiler/mlir/lite/flatbuffer_export.cc:2989] Estimated count of arithmetic ops: 9.246 G  ops, equivalently 4.623 G  MACs
```