[TF-TRT] Fix repeated layer name bug
@aboubezari thanks for the PR! Good catch.

Would you mind adding one tiny unittest that shows without your fix it fails and with your fix it works?
That way I can merge it and make sure it doesn't happen again > @aboubezari thanks for the PR! Good catch.
> 
> Would you mind adding one tiny unittest that shows without your fix it fails and with your fix it works? That way I can merge it and make sure it doesn't happen again

I'm working on building the unittests properly on my machine, will get back to you, thanks @DEKHTIARJonathan I tried reproducing the issue on `convert_nodes_test.cc`, but I'm realizing that this is not a conversion-time error, but this is something that happens when we attempt to execute the engine at inference time, so the UT is not useful at the moment. 

Since this is a low-risk change, what do you think about merging it as is?  @nluehr @pjannaty @poulsbo @DEKHTIARJonathan friendly ping here, what do we think is the best next step forward? > I tried reproducing the issue on convert_nodes_test.cc, but I'm realizing that this is not a conversion-time error, but this is something that happens when we attempt to execute the engine at inference time, so the UT is not useful at the moment.

TF-TRT code is not executed at runtime. There is conversion aka. segmentation time and engine build time (which happens prior the first execution).

It should still be possible to write a unittest.

If you can identify which layer is leading to the problem, we should be able to replicate very simply with a unittest.

Indeed the problem is fairly simple and low risk, however it is of good practice to merge a change/bugfix with a unittest :)
If you are not able to write the unittest please provide a 1-2 layers networks that shows the issues. Don't forget to set `minimum_segment_size=1`

Feel free to use this template to show us the problem:

```python
import tensorflow as tf

tf.get_logger().setLevel('INFO')

INPUT_SIZE = (512, 5000)
SAVED_MODEL_DIR="/tmp/1234"


if __name__ == "__main__":

    # Create a basic model instance
    model = tf.keras.models.Sequential([
        tf.keras.layers.Dense(4096, activation='relu'),
    ])
    
    # Build model - randomly initialized
    _ = model(tf.random.uniform(INPUT_SIZE))

    # Save Model
    model.save(SAVED_MODEL_DIR)
    
    # =================== INFERENCE ================ #
    from tensorflow.python.saved_model import signature_constants
    from tensorflow.python.saved_model import tag_constants
    from tensorflow.python.compiler.tensorrt import trt_convert as trt

    converter = trt.TrtGraphConverterV2(
        input_saved_model_dir=SAVED_MODEL_DIR,
        input_saved_model_tags=[tag_constants.SERVING],
        input_saved_model_signature_key=signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY,
        precision_mode=trt.TrtPrecisionMode.FP32,
        minimum_segment_size=1
    )

    func = converter.convert()

    converter.summary()

    data = tf.random.uniform(INPUT_SIZE)
    for step in range(1, 20):
        print(f"Step: {step + 1}/50")
        _ = func(data).numpy()
``` Hey @DEKHTIARJonathan, 
I wanted to confirm whether this is an inference time error not, so I re-ran my own test case with a custom layer. 
As you can see below, the engine is created successfully, and when we execute the tensorrt network created by the converter, the inference fails in tensorrt and falls back to the native segment, which I don't want. With this change, the failure is resolved. 
I am working on a reproducible error with native tensorflow components. Based on this, do you have recommendations on how to catch it in a unittest? 
Here's the log:
```
W20230410 06:52:48.092698 2334411 trt_optimization_pass.cc:186] Calibration with FP32 or FP16 is not implemented. Falling back to use_calibration = False.Note that the default value of use_calibration is True.
W20230410 06:52:48.093089 2334411 segment.cc:956] 

################################################################################
TensorRT unsupported/non-converted OP Report:
        - Identity -> 3x
                - [Count: 3x] excluded by segmenter option. Most likely an input or output node.

        - Placeholder -> 3x
                - [Count: 3x] excluded by segmenter option. Most likely an input or output node.

        - NoOp -> 2x
                - [Count: 2x] Op type NoOp is not supported.

--------------------------------------------------------------------------------
        - Total nonconverted OPs: 8
        - Total nonconverted OP Types: 3
For more information see https://docs.nvidia.com/deeplearning/frameworks/tf-trt-user-guide/index.html#supported-ops.
################################################################################
W20230410 06:52:48.093191 2334411 segment.cc:1284] The environment variable TF_TRT_MAX_ALLOWED_ENGINES=20 has no effect since there are only 1 TRT Engines with  at least minimum_segment_size=1 nodes.
I20230410 06:52:48.093217 2334411 convert_graph.cc:795] Number of TensorRT candidate segments: 1
I20230410 06:52:48.101868 2334411 convert_graph.cc:909] Replaced segment 0 consisting of 1 nodes by TRTEngineOp_000_000.
WARNING: Logging before InitGoogleLogging() is written to STDERR
I20230410 06:52:48.296857 2334263 utils.cc:100] Linked TensorRT version: 8.5.1
I20230410 06:52:48.296913 2334263 utils.cc:102] Loaded TensorRT version: 8.5.1
W20230410 06:52:52.116518 2334263 trt_logger.cc:36] TF-TRT Warning: DefaultLogger CUDA lazy loading is not enabled. Enabling it can significantly reduce device memory usage. See `CUDA_MODULE_LOADING` in https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-vars
E20230410 06:52:52.150035 2334263 trt_logger.cc:40] DefaultLogger 4: [network.cpp::validate::2760] Error Code 4: Internal Error (Repeated layer name: TRTEngineOp_000_000/PartitionedCall/model/tf.nuro_detection_output/DetectionOutput-shuffle:SHUFFLE (layers must have distinct names))
W20230410 06:52:52.204959 2334263 trt_engine_op.cc:1046] TF-TRT Warning: Engine creation for TRTEngineOp_000_000 failed. The native segment will be used instead. Reason: INTERNAL: Failed to build TensorRT engine
W20230410 06:52:52.205046 2334263 trt_engine_op.cc:887] TF-TRT Warning: Engine retrieval for input shapes: [[1,1600], [1,4000], [1,2000]] failed. Running native segment for TRTEngineOp_000_000
I0410 06:52:52.370252 2334179 builder_impl.py:780] Assets written to: /tmp/tmp3mqez0ti/test_model_trt/assets
TRTEngineOP Name                 Device        # Nodes # Inputs      # Outputs     Input DTypes       Output Dtypes      Input Shapes       Output Shapes     
================================================================================================================================================================
TRTEngineOp_000_000              device:GPU:0  1       3             3             ['float32', 'f ... ['float32', 'i ... [[1, 1600], [1 ... [[200, 8], [1] ...

        - DetectionOutput: 1x

================================================================================================================================================================
[*] Total number of TensorRT engines: 1
[*] % of OPs Converted: 14.29% [1/7]
***
Starting tensorrt vs. tf inference:
W20230410 06:52:55.758549 2334264 trt_logger.cc:36] TF-TRT Warning: DefaultLogger CUDA lazy loading is not enabled. Enabling it can significantly reduce device memory usage. See `CUDA_MODULE_LOADING` in https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-vars
E20230410 06:52:55.789471 2334264 trt_logger.cc:40] DefaultLogger 4: [network.cpp::validate::2760] Error Code 4: Internal Error (Repeated layer name: PartitionedCall/TRTEngineOp_000_000/PartitionedCall/model/tf.nuro_detection_output/DetectionOutput-shuffle:SHUFFLE (layers must have distinct names))
W20230410 06:52:55.837152 2334264 trt_engine_op.cc:1046] TF-TRT Warning: Engine creation for PartitionedCall/TRTEngineOp_000_000 failed. The native segment will be used instead. Reason: INTERNAL: Failed to build TensorRT engine
W20230410 06:52:55.837267 2334264 trt_engine_op.cc:887] TF-TRT Warning: Engine retrieval for input shapes: [[1,1600], [1,4000], [1,2000]] failed. Running native segment for PartitionedCall/TRTEngineOp_000_000
```
 Actually, I do this conversion warning: 
```
TF-TRT Warning: Engine creation for TRTEngineOp_000_000 failed. The native segment will be used instead. Reason: INTERNAL: Failed to build TensorRT engine
```
Let me keep trying to resurface this :)  Ok, I realized what I was missing: I was not calling `BuildAndRun` in the unittest to actually build & test the network. 

I've added the unittest and confirmed that it fails without my change and passes with it. 

@nluehr @pjannaty @poulsbo @DEKHTIARJonathan can we take one more look? It should be ready 👍  ## Unittest results 

**Command**: 
```
bazel build -c opt --copt="-Wno-error=switch" tensorflow/compiler/tf2tensorrt:convert_nodes_test && bazel-bin/tensorflow/compiler/tf2tensorrt/convert_nodes_test_gpu --gtest_filter="OpConverterTest.DuplicateSqueeze"
```

**With my change:**
```
Note: Google Test filter = OpConverterTest.DuplicateSqueeze
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from OpConverterTest
[ RUN      ] OpConverterTest.DuplicateSqueeze
2023-04-10 16:09:25.417162: I tensorflow/compiler/tf2tensorrt/common/utils.cc:104] Linked TensorRT version: 8.6.0
2023-04-10 16:09:25.417259: I tensorflow/compiler/tf2tensorrt/common/utils.cc:106] Loaded TensorRT version: 8.6.0
2023-04-10 16:09:25.463796: W tensorflow/compiler/tf2tensorrt/convert/op_converter_registry.cc:55] Overwriting TF->TRT Abs op converter with priority 1 using another converter with priority 2
2023-04-10 16:09:25.468067: I tensorflow/compiler/tf2tensorrt/convert/convert_nodes.cc:1330] [TF-TRT] Sparse compute capability: enabled.
[       OK ] OpConverterTest.DuplicateSqueeze (323 ms)
[----------] 1 test from OpConverterTest (323 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (323 ms total)
[  PASSED  ] 1 test.
```

**Without my change:** 
```
Note: Google Test filter = OpConverterTest.DuplicateSqueeze
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from OpConverterTest
[ RUN      ] OpConverterTest.DuplicateSqueeze
2023-04-10 16:13:13.607505: I tensorflow/compiler/tf2tensorrt/common/utils.cc:104] Linked TensorRT version: 8.6.0
2023-04-10 16:13:13.607600: I tensorflow/compiler/tf2tensorrt/common/utils.cc:106] Loaded TensorRT version: 8.6.0
2023-04-10 16:13:13.654402: W tensorflow/compiler/tf2tensorrt/convert/op_converter_registry.cc:55] Overwriting TF->TRT Abs op converter with priority 1 using another converter with priority 2
2023-04-10 16:13:13.658712: I tensorflow/compiler/tf2tensorrt/convert/convert_nodes.cc:1330] [TF-TRT] Sparse compute capability: enabled.
2023-04-10 16:13:13.695280: E tensorflow/compiler/tf2tensorrt/utils/trt_logger.cc:87] DefaultLogger 4: [network.cpp::validate::2783] Error Code 4: Internal Error (Repeated layer name: /my_unary-shuffle:SHUFFLE (layers must have distinct names))
tensorflow/compiler/tf2tensorrt/convert/convert_nodes_test.cc:9891: Failure
Expected equality of these values:
  ::tsl::OkStatus()
    Which is: OK
  (BuildAndRun(input_data, &outputs))
    Which is: INTERNAL: Failed to build TensorRT engine
[  FAILED  ] OpConverterTest.DuplicateSqueeze (214 ms)
[----------] 1 test from OpConverterTest (214 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (214 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] OpConverterTest.DuplicateSqueeze

 1 FAILED TEST
``` @DEKHTIARJonathan quick ping, let me know if there's anything else, I think we're close here :) 

 @nluehr @pjannaty @poulsbo @DEKHTIARJonathan another friendly ping :)
Could we take a look please? We should be all good now with unittest coverage. 

 @nluehr @pjannaty @poulsbo @DEKHTIARJonathan one last ping for a while. I'm going on vacation for 2-3 weeks after today so would be great to take a look in that time, thanks! LGTM approved
## Issue
When there are multiple invocations of `SqueezeTensor` in a layer, the converter will complain: 
```
Repeated layer name: TRTEngineOp_000_000/PartitionedCall/model/tf.detection_output/DetectionOutput-shuffle:SHUFFLE (layers must have distinct names))
```
This happens despite passing `op_instance` to `SqueezeTensor`. The root cause is `op_instance` not being propagated to `PrepareTensorForShape`. 

## Fix
Propagate the `op_instance` argument to the internal `PrepareTensorForShape` call. Tested that a >1000 node graph completed with no issues. Add unit test coverage to prevent this issue from happening again.