prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  🐛 [Bug] Issue in `ConstantFolder` where certain operators no longer exist in latest nightly
  ##  Bug Description
  
  [See here](https://github.com/pytorch/pytorch/blob/4b881b0da390c1290bb12850ef9daad6f6eb2cb6/torch/_inductor/constant_folding.py#L53-L63)
  
  ## To Reproduce
  
  See recent PR 
  
  ## Expected behavior
  
  These tests should not fail.
  
  ## Environment
  
  > Build information about Torch-TensorRT can be found by turning on debug messages
  
   - Torch-TensorRT Version (e.g. 1.0.0): https://github.com/pytorch/TensorRT/commit/0ef47c78ce94f610ee2a3a5a62e6fb450d4a8b34
   - PyTorch Version (e.g. 1.0): `2.2.0.dev20231009+cu121`
  
  
  </issue>
  <code>
  [start of py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py]
  1 import logging
  2 from typing import Sequence
  3 
  4 import torch
  5 from torch_tensorrt._utils import sanitized_torch_version
  6 from torch_tensorrt.dynamo.lowering.passes.pass_utils import (
  7     clean_up_graph_after_modifications,
  8 )
  9 
  10 from packaging import version
  11 
  12 # Modify import location of utilities based on Torch version
  13 if version.parse(sanitized_torch_version()) < version.parse("2.1.1"):
  14     from torch._inductor.freezing import ConstantFolder, replace_node_with_constant
  15 else:
  16     from torch._inductor.constant_folding import (
  17         ConstantFolder,
  18         replace_node_with_constant,
  19     )
  20 
  21 logger = logging.getLogger(__name__)
  22 
  23 
  24 @torch.utils._python_dispatch._disable_current_modes()  # type: ignore
  25 def constant_fold(
  26     gm: torch.fx.GraphModule, sample_inputs: Sequence[torch.Tensor]
  27 ) -> torch.fx.GraphModule:
  28     """Adapted from:
  29     https://github.com/pytorch/pytorch/blob/3a79621c9dce17f77fbddc06aab21f6bc477f313/torch/_inductor/freezing.py#L178-L197
  30 
  31     Folds constants in the graph module, not skipping constructors
  32 
  33     Modifies the graph in-place and replaces node with constants
  34     """
  35     cf = ConstantFolder(gm, skip_constructors=False)
  36     cf.run()
  37 
  38     for node, constant in cf.node_replacements.items():
  39         replace_node_with_constant(gm, node, constant)
  40 
  41     erased_params = []
  42     for node in gm.graph.nodes:
  43         # If get_attr node has no users, mark it for deletion
  44         if node.op == "get_attr" and len(node.users) == 0:
  45             # If the node's parameter is not a parameter of any other node, remove it
  46             if not any(
  47                 other.target == node.target for other in gm.graph.nodes if other != node
  48             ):
  49                 delattr(gm, node.target)
  50             erased_params.append(node)
  51 
  52     # Remove unused nodes from the graph
  53     for node in erased_params:
  54         gm.graph.erase_node(node)
  55 
  56     gm = clean_up_graph_after_modifications(gm)
  57 
  58     logger.debug(f"Graph after constant folding:\n{gm.graph}")
  59 
  60     return gm
  61
  [end of py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py b/py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py
  --- a/py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py
  +++ b/py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py
  @@ -1,5 +1,5 @@
   import logging
  -from typing import Sequence
  +from typing import Any, Sequence
   
   import torch
   from torch_tensorrt._utils import sanitized_torch_version
  @@ -32,7 +32,7 @@
   
       Modifies the graph in-place and replaces node with constants
       """
  -    cf = ConstantFolder(gm, skip_constructors=False)
  +    cf = _TorchTensorRTConstantFolder(gm, skip_constructors=False)
       cf.run()
   
       for node, constant in cf.node_replacements.items():
  @@ -58,3 +58,14 @@
       logger.debug(f"Graph after constant folding:\n{gm.graph}")
   
       return gm
  +
  +
  +# TODO: Delete this class when the following code is fixed in nightly:
  +# https://github.com/pytorch/pytorch/blob/4b881b0da390c1290bb12850ef9daad6f6eb2cb6/torch/_inductor/constant_folding.py#L53-L63
  +class _TorchTensorRTConstantFolder(ConstantFolder):  # type: ignore[misc]
  +    def __init__(self, *args: Any, **kwargs: Any) -> None:
  +        super().__init__(*args, **kwargs)
  +
  +    # TODO: Update this function when quantization is added
  +    def is_impure(self, node: torch.fx.node.Node) -> bool:
  +        return False
  
verification_info: {"golden_diff": "diff --git a/py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py b/py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py\n--- a/py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py\n+++ b/py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py\n@@ -1,5 +1,5 @@\n import logging\n-from typing import Sequence\n+from typing import Any, Sequence\n \n import torch\n from torch_tensorrt._utils import sanitized_torch_version\n@@ -32,7 +32,7 @@\n \n     Modifies the graph in-place and replaces node with constants\n     \"\"\"\n-    cf = ConstantFolder(gm, skip_constructors=False)\n+    cf = _TorchTensorRTConstantFolder(gm, skip_constructors=False)\n     cf.run()\n \n     for node, constant in cf.node_replacements.items():\n@@ -58,3 +58,14 @@\n     logger.debug(f\"Graph after constant folding:\\n{gm.graph}\")\n \n     return gm\n+\n+\n+# TODO: Delete this class when the following code is fixed in nightly:\n+# https://github.com/pytorch/pytorch/blob/4b881b0da390c1290bb12850ef9daad6f6eb2cb6/torch/_inductor/constant_folding.py#L53-L63\n+class _TorchTensorRTConstantFolder(ConstantFolder):  # type: ignore[misc]\n+    def __init__(self, *args: Any, **kwargs: Any) -> None:\n+        super().__init__(*args, **kwargs)\n+\n+    # TODO: Update this function when quantization is added\n+    def is_impure(self, node: torch.fx.node.Node) -> bool:\n+        return False\n", "issue": "\ud83d\udc1b [Bug] Issue in `ConstantFolder` where certain operators no longer exist in latest nightly\n##  Bug Description\r\n\r\n[See here](https://github.com/pytorch/pytorch/blob/4b881b0da390c1290bb12850ef9daad6f6eb2cb6/torch/_inductor/constant_folding.py#L53-L63)\r\n\r\n## To Reproduce\r\n\r\nSee recent PR \r\n\r\n## Expected behavior\r\n\r\nThese tests should not fail.\r\n\r\n## Environment\r\n\r\n> Build information about Torch-TensorRT can be found by turning on debug messages\r\n\r\n - Torch-TensorRT Version (e.g. 1.0.0): https://github.com/pytorch/TensorRT/commit/0ef47c78ce94f610ee2a3a5a62e6fb450d4a8b34\r\n - PyTorch Version (e.g. 1.0): `2.2.0.dev20231009+cu121`\r\n\n", "before_files": [{"content": "import logging\nfrom typing import Sequence\n\nimport torch\nfrom torch_tensorrt._utils import sanitized_torch_version\nfrom torch_tensorrt.dynamo.lowering.passes.pass_utils import (\n    clean_up_graph_after_modifications,\n)\n\nfrom packaging import version\n\n# Modify import location of utilities based on Torch version\nif version.parse(sanitized_torch_version()) < version.parse(\"2.1.1\"):\n    from torch._inductor.freezing import ConstantFolder, replace_node_with_constant\nelse:\n    from torch._inductor.constant_folding import (\n        ConstantFolder,\n        replace_node_with_constant,\n    )\n\nlogger = logging.getLogger(__name__)\n\n\n@torch.utils._python_dispatch._disable_current_modes()  # type: ignore\ndef constant_fold(\n    gm: torch.fx.GraphModule, sample_inputs: Sequence[torch.Tensor]\n) -> torch.fx.GraphModule:\n    \"\"\"Adapted from:\n    https://github.com/pytorch/pytorch/blob/3a79621c9dce17f77fbddc06aab21f6bc477f313/torch/_inductor/freezing.py#L178-L197\n\n    Folds constants in the graph module, not skipping constructors\n\n    Modifies the graph in-place and replaces node with constants\n    \"\"\"\n    cf = ConstantFolder(gm, skip_constructors=False)\n    cf.run()\n\n    for node, constant in cf.node_replacements.items():\n        replace_node_with_constant(gm, node, constant)\n\n    erased_params = []\n    for node in gm.graph.nodes:\n        # If get_attr node has no users, mark it for deletion\n        if node.op == \"get_attr\" and len(node.users) == 0:\n            # If the node's parameter is not a parameter of any other node, remove it\n            if not any(\n                other.target == node.target for other in gm.graph.nodes if other != node\n            ):\n                delattr(gm, node.target)\n            erased_params.append(node)\n\n    # Remove unused nodes from the graph\n    for node in erased_params:\n        gm.graph.erase_node(node)\n\n    gm = clean_up_graph_after_modifications(gm)\n\n    logger.debug(f\"Graph after constant folding:\\n{gm.graph}\")\n\n    return gm\n", "path": "py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py"}]}