We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Expose ISelectLayer in dynamo.conversion.impl


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `py/torch_tensorrt/dynamo/conversion/impl/condition/ops.py`
Content:
```
1 from typing import Optional, Union
2 
3 import numpy as np
4 import tensorrt as trt
5 import torch
6 from torch.fx.node import Target
7 from torch_tensorrt.dynamo._SourceIR import SourceIR
8 from torch_tensorrt.dynamo.conversion._ConversionContext import ConversionContext
9 from torch_tensorrt.dynamo.conversion.converter_utils import (
10     broadcastable,
11     get_trt_tensor,
12 )
13 from torch_tensorrt.dynamo.conversion.impl.slice import expand
14 from torch_tensorrt.fx.converters.converter_utils import set_layer_name
15 from torch_tensorrt.fx.types import TRTTensor
16 
17 
18 def where(
19     ctx: ConversionContext,
20     target: Target,
21     source_ir: Optional[SourceIR],
22     name: str,
23     input: Union[TRTTensor, np.ndarray, torch.Tensor],
24     other: Union[TRTTensor, np.ndarray, torch.Tensor],
25     condition: Union[TRTTensor, np.ndarray, torch.Tensor],
26 ) -> TRTTensor:
27     if not (broadcastable(input, other)):
28         assert "The two torch tensors should be broadcastable"
29 
30     x_shape = list(input.shape)
31     y_shape = list(other.shape)
32     condition_shape = list(condition.shape)
33 
34     output_shape = list(torch.broadcast_shapes(condition_shape, x_shape, y_shape))
35 
36     # expand shape
37     if not isinstance(condition, TRTTensor):
38         assert condition.dtype in (torch.bool, np.bool_), "condition dtype is not bool"
39         if condition_shape != output_shape:
40             condition = (
41                 condition.expand(output_shape)
42                 if isinstance(condition, torch.Tensor)
43                 else np.broadcast_to(condition, output_shape)
44             )
45         condition_val = get_trt_tensor(ctx, condition, f"{name}_condition")
46     else:
47         assert condition.dtype == trt.bool, "mask dtype is not bool!"
48         if condition_shape != output_shape:
49             condition_val = expand(
50                 ctx, target, source_ir, f"{name}_expand", condition, output_shape
51             )
52         else:
53             condition_val = condition
54 
55     if not isinstance(input, TRTTensor):
56         if x_shape != output_shape:
57             # special case where 1 element in input
58             if len(input.shape) == 0:
59                 input = (
60                     input.unsqueeze(0)
61                     if isinstance(input, torch.Tensor)
62                     else np.expand_dims(input, axis=0)
63                 )
64             input = (
65                 input.expand(output_shape)
66                 if isinstance(input, torch.Tensor)
67                 else np.broadcast_to(input, output_shape)
68             )
69         x_val = get_trt_tensor(ctx, input, f"{name}_x")
70     else:
71         x_val = input
72         if x_shape != output_shape:
73             x_val = expand(
74                 ctx, target, source_ir, f"{name}_x_expand", input, output_shape
75             )
76 
77     if not isinstance(other, TRTTensor):
78         if y_shape != output_shape:
79             # special case where 1 element in other
80             if len(other.shape) == 0:
81                 other = (
82                     other.unsqueeze(0)
83                     if isinstance(other, torch.Tensor)
84                     else np.expand_dims(other, axis=0)
85                 )
86             other = (
87                 other.expand(output_shape)
88                 if isinstance(other, torch.Tensor)
89                 else np.broadcast_to(other, output_shape)
90             )
91         y_val = get_trt_tensor(ctx, other, f"{name}_y")
92     else:
93         y_val = other
94         if y_shape != output_shape:
95             y_val = expand(
96                 ctx, target, source_ir, f"{name}_y_expand", y_val, output_shape
97             )
98 
99     select_layer = ctx.net.add_select(condition_val, x_val, y_val)
100 
101     set_layer_name(select_layer, target, f"{name}_select")
102 
103     return select_layer.get_output(0)
104
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/py/torch_tensorrt/dynamo/conversion/impl/condition/ops.py b/py/torch_tensorrt/dynamo/conversion/impl/condition/ops.py
--- a/py/torch_tensorrt/dynamo/conversion/impl/condition/ops.py
+++ b/py/torch_tensorrt/dynamo/conversion/impl/condition/ops.py
@@ -96,8 +96,18 @@
                 ctx, target, source_ir, f"{name}_y_expand", y_val, output_shape
             )
 
-    select_layer = ctx.net.add_select(condition_val, x_val, y_val)
+    return select(ctx, target, source_ir, name, x_val, y_val, condition_val)
 
-    set_layer_name(select_layer, target, f"{name}_select")
 
+def select(
+    ctx: ConversionContext,
+    target: Target,
+    source_ir: Optional[SourceIR],
+    name: str,
+    input: TRTTensor,
+    other: TRTTensor,
+    condition: TRTTensor,
+) -> TRTTensor:
+    select_layer = ctx.net.add_select(condition, input, other)
+    set_layer_name(select_layer, target, name + "_select", source_ir)
     return select_layer.get_output(0)

{"golden_diff": "diff --git a/py/torch_tensorrt/dynamo/conversion/impl/condition/ops.py b/py/torch_tensorrt/dynamo/conversion/impl/condition/ops.py\n--- a/py/torch_tensorrt/dynamo/conversion/impl/condition/ops.py\n+++ b/py/torch_tensorrt/dynamo/conversion/impl/condition/ops.py\n@@ -96,8 +96,18 @@\n                 ctx, target, source_ir, f\"{name}_y_expand\", y_val, output_shape\n             )\n \n-    select_layer = ctx.net.add_select(condition_val, x_val, y_val)\n+    return select(ctx, target, source_ir, name, x_val, y_val, condition_val)\n \n-    set_layer_name(select_layer, target, f\"{name}_select\")\n \n+def select(\n+    ctx: ConversionContext,\n+    target: Target,\n+    source_ir: Optional[SourceIR],\n+    name: str,\n+    input: TRTTensor,\n+    other: TRTTensor,\n+    condition: TRTTensor,\n+) -> TRTTensor:\n+    select_layer = ctx.net.add_select(condition, input, other)\n+    set_layer_name(select_layer, target, name + \"_select\", source_ir)\n     return select_layer.get_output(0)\n", "issue": "Expose ISelectLayer in dynamo.conversion.impl\n\n", "before_files": [{"content": "from typing import Optional, Union\n\nimport numpy as np\nimport tensorrt as trt\nimport torch\nfrom torch.fx.node import Target\nfrom torch_tensorrt.dynamo._SourceIR import SourceIR\nfrom torch_tensorrt.dynamo.conversion._ConversionContext import ConversionContext\nfrom torch_tensorrt.dynamo.conversion.converter_utils import (\n    broadcastable,\n    get_trt_tensor,\n)\nfrom torch_tensorrt.dynamo.conversion.impl.slice import expand\nfrom torch_tensorrt.fx.converters.converter_utils import set_layer_name\nfrom torch_tensorrt.fx.types import TRTTensor\n\n\ndef where(\n    ctx: ConversionContext,\n    target: Target,\n    source_ir: Optional[SourceIR],\n    name: str,\n    input: Union[TRTTensor, np.ndarray, torch.Tensor],\n    other: Union[TRTTensor, np.ndarray, torch.Tensor],\n    condition: Union[TRTTensor, np.ndarray, torch.Tensor],\n) -> TRTTensor:\n    if not (broadcastable(input, other)):\n        assert \"The two torch tensors should be broadcastable\"\n\n    x_shape = list(input.shape)\n    y_shape = list(other.shape)\n    condition_shape = list(condition.shape)\n\n    output_shape = list(torch.broadcast_shapes(condition_shape, x_shape, y_shape))\n\n    # expand shape\n    if not isinstance(condition, TRTTensor):\n        assert condition.dtype in (torch.bool, np.bool_), \"condition dtype is not bool\"\n        if condition_shape != output_shape:\n            condition = (\n                condition.expand(output_shape)\n                if isinstance(condition, torch.Tensor)\n                else np.broadcast_to(condition, output_shape)\n            )\n        condition_val = get_trt_tensor(ctx, condition, f\"{name}_condition\")\n    else:\n        assert condition.dtype == trt.bool, \"mask dtype is not bool!\"\n        if condition_shape != output_shape:\n            condition_val = expand(\n                ctx, target, source_ir, f\"{name}_expand\", condition, output_shape\n            )\n        else:\n            condition_val = condition\n\n    if not isinstance(input, TRTTensor):\n        if x_shape != output_shape:\n            # special case where 1 element in input\n            if len(input.shape) == 0:\n                input = (\n                    input.unsqueeze(0)\n                    if isinstance(input, torch.Tensor)\n                    else np.expand_dims(input, axis=0)\n                )\n            input = (\n                input.expand(output_shape)\n                if isinstance(input, torch.Tensor)\n                else np.broadcast_to(input, output_shape)\n            )\n        x_val = get_trt_tensor(ctx, input, f\"{name}_x\")\n    else:\n        x_val = input\n        if x_shape != output_shape:\n            x_val = expand(\n                ctx, target, source_ir, f\"{name}_x_expand\", input, output_shape\n            )\n\n    if not isinstance(other, TRTTensor):\n        if y_shape != output_shape:\n            # special case where 1 element in other\n            if len(other.shape) == 0:\n                other = (\n                    other.unsqueeze(0)\n                    if isinstance(other, torch.Tensor)\n                    else np.expand_dims(other, axis=0)\n                )\n            other = (\n                other.expand(output_shape)\n                if isinstance(other, torch.Tensor)\n                else np.broadcast_to(other, output_shape)\n            )\n        y_val = get_trt_tensor(ctx, other, f\"{name}_y\")\n    else:\n        y_val = other\n        if y_shape != output_shape:\n            y_val = expand(\n                ctx, target, source_ir, f\"{name}_y_expand\", y_val, output_shape\n            )\n\n    select_layer = ctx.net.add_select(condition_val, x_val, y_val)\n\n    set_layer_name(select_layer, target, f\"{name}_select\")\n\n    return select_layer.get_output(0)\n", "path": "py/torch_tensorrt/dynamo/conversion/impl/condition/ops.py"}], "after_files": [{"content": "from typing import Optional, Union\n\nimport numpy as np\nimport tensorrt as trt\nimport torch\nfrom torch.fx.node import Target\nfrom torch_tensorrt.dynamo._SourceIR import SourceIR\nfrom torch_tensorrt.dynamo.conversion._ConversionContext import ConversionContext\nfrom torch_tensorrt.dynamo.conversion.converter_utils import (\n    broadcastable,\n    get_trt_tensor,\n)\nfrom torch_tensorrt.dynamo.conversion.impl.slice import expand\nfrom torch_tensorrt.fx.converters.converter_utils import set_layer_name\nfrom torch_tensorrt.fx.types import TRTTensor\n\n\ndef where(\n    ctx: ConversionContext,\n    target: Target,\n    source_ir: Optional[SourceIR],\n    name: str,\n    input: Union[TRTTensor, np.ndarray, torch.Tensor],\n    other: Union[TRTTensor, np.ndarray, torch.Tensor],\n    condition: Union[TRTTensor, np.ndarray, torch.Tensor],\n) -> TRTTensor:\n    if not (broadcastable(input, other)):\n        assert \"The two torch tensors should be broadcastable\"\n\n    x_shape = list(input.shape)\n    y_shape = list(other.shape)\n    condition_shape = list(condition.shape)\n\n    output_shape = list(torch.broadcast_shapes(condition_shape, x_shape, y_shape))\n\n    # expand shape\n    if not isinstance(condition, TRTTensor):\n        assert condition.dtype in (torch.bool, np.bool_), \"condition dtype is not bool\"\n        if condition_shape != output_shape:\n            condition = (\n                condition.expand(output_shape)\n                if isinstance(condition, torch.Tensor)\n                else np.broadcast_to(condition, output_shape)\n            )\n        condition_val = get_trt_tensor(ctx, condition, f\"{name}_condition\")\n    else:\n        assert condition.dtype == trt.bool, \"mask dtype is not bool!\"\n        if condition_shape != output_shape:\n            condition_val = expand(\n                ctx, target, source_ir, f\"{name}_expand\", condition, output_shape\n            )\n        else:\n            condition_val = condition\n\n    if not isinstance(input, TRTTensor):\n        if x_shape != output_shape:\n            # special case where 1 element in input\n            if len(input.shape) == 0:\n                input = (\n                    input.unsqueeze(0)\n                    if isinstance(input, torch.Tensor)\n                    else np.expand_dims(input, axis=0)\n                )\n            input = (\n                input.expand(output_shape)\n                if isinstance(input, torch.Tensor)\n                else np.broadcast_to(input, output_shape)\n            )\n        x_val = get_trt_tensor(ctx, input, f\"{name}_x\")\n    else:\n        x_val = input\n        if x_shape != output_shape:\n            x_val = expand(\n                ctx, target, source_ir, f\"{name}_x_expand\", input, output_shape\n            )\n\n    if not isinstance(other, TRTTensor):\n        if y_shape != output_shape:\n            # special case where 1 element in other\n            if len(other.shape) == 0:\n                other = (\n                    other.unsqueeze(0)\n                    if isinstance(other, torch.Tensor)\n                    else np.expand_dims(other, axis=0)\n                )\n            other = (\n                other.expand(output_shape)\n                if isinstance(other, torch.Tensor)\n                else np.broadcast_to(other, output_shape)\n            )\n        y_val = get_trt_tensor(ctx, other, f\"{name}_y\")\n    else:\n        y_val = other\n        if y_shape != output_shape:\n            y_val = expand(\n                ctx, target, source_ir, f\"{name}_y_expand\", y_val, output_shape\n            )\n\n    return select(ctx, target, source_ir, name, x_val, y_val, condition_val)\n\n\ndef select(\n    ctx: ConversionContext,\n    target: Target,\n    source_ir: Optional[SourceIR],\n    name: str,\n    input: TRTTensor,\n    other: TRTTensor,\n    condition: TRTTensor,\n) -> TRTTensor:\n    select_layer = ctx.net.add_select(condition, input, other)\n    set_layer_name(select_layer, target, name + \"_select\", source_ir)\n    return select_layer.get_output(0)\n", "path": "py/torch_tensorrt/dynamo/conversion/impl/condition/ops.py"}]}