We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Dynamo WONT CONVERT for is_fx_tracing()
Probably the same as #1009. Repro:
```
import torchdynamo
from torch.fx._symbolic_trace import is_fx_tracing

def my_compiler(gm, inputs):
    return gm.forward

@torchdynamo.optimize(my_compiler)
def fn(x, y):
    if is_fx_tracing():
        return x
    else:
        return y

fn(1, 2)
```
returns
```
torchdynamo.convert_frame: [ERROR] WON'T CONVERT fn /private/home/suo/scratch/test.py line 8
due to:
Traceback (most recent call last):
  File "/raid/suo/torchdynamo/torchdynamo/variables/tensor.py", line 258, in create
    assert (
AssertionError: torch.* op returned non-Tensor bool call_function <function is_fx_tracing at 0x7f08b681e700>

from user code:
   File "/private/home/suo/scratch/test.py", line 10, in fn
    if is_fx_tracing():

Set torchdynamo.config.verbose=True for more information
==========
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `torchdynamo/config.py`
Content:
```
1 import logging
2 import os
3 import sys
4 from os.path import abspath
5 from os.path import dirname
6 from types import ModuleType
7 
8 import torch
9 
10 try:
11     import torch._prims
12     import torch._refs
13 
14     HAS_REFS_PRIMS = True
15 except ImportError:
16     HAS_REFS_PRIMS = False
17 
18 
19 class AccessLimitingConfig(ModuleType):
20     # log level (levels print what it says + all levels listed below it)
21     # DEBUG print full traces <-- lowest level + print tracing of every instruction
22     # INFO print compiled functions + graphs
23     # WARN print warnings (including graph breaks)
24     # ERROR print exceptions (and what user code was being processed when it occurred)
25     log_level = logging.WARNING
26     # Verbose will print full stack traces on warnings and errors
27     verbose = False
28 
29     # verify the correctness of optimized backend
30     verify_correctness = False
31 
32     # need this many ops to create an FX graph
33     minimum_call_count = 1
34 
35     # turn on/off DCE pass
36     dead_code_elimination = True
37 
38     # disable (for a function) when cache reaches this size
39     cache_size_limit = 64
40 
41     # specializing int/float by default
42     specialize_int_float = True
43 
44     # Assume these functions return constants
45     constant_functions = {
46         torch.jit.is_scripting: False,
47         torch.jit.is_tracing: False,
48         torch._C._get_tracing_state: None,
49     }
50 
51     # root folder of the project
52     base_dir = dirname(dirname(abspath(__file__)))
53 
54     # don't specialize on shapes and strides and put shape ops in graph
55     dynamic_shapes = os.environ.get("TORCHDYNAMO_DYNAMIC_SHAPES") == "1"
56 
57     # Set this to False to assume nn.Modules() contents are immutable (similar assumption as freezing)
58     guard_nn_modules = False
59 
60     # Run the FX graph as it is created to get better type information
61     dynamic_propagation = True
62 
63     # Run the FX graph with FakeTensors
64     fake_tensor_propagation = True
65 
66     # run FX normalization passes in optimizer
67     normalize_ir = True
68 
69     # If a tensor subclass type is in this set, torchdynamo will inline the
70     # __torch_function__ logic of the subclass.
71     traceable_tensor_subclasses = set()
72 
73     # Raise torchdynamo internal assertions
74     raise_on_assertion_error = False
75 
76     # Propagate backend exceptions up to torchdynamo.optimize
77     raise_on_backend_error = True
78 
79     # If a PyTorch module is in this allowlist, torchdynamo will be allowed
80     # to inline objects from it or its children.
81     skipfiles_inline_module_allowlist = {torch.nn, torch.distributions}
82     if HAS_REFS_PRIMS:
83         skipfiles_inline_module_allowlist |= {
84             torch._refs,
85             torch._prims,
86             torch._decomp,
87         }
88 
89     # If a string representing a PyTorch module is in this ignorelist,
90     # the `allowed_functions.is_allowed` function will not consider it
91     # when creating a list of PyTorch functions that will appear in
92     # FX IR.
93     allowed_functions_module_string_ignorelist = {
94         "torch.distributions",
95         "torch.testing",
96         "torch._refs",
97         "torch._prims",
98         "torch._decomp",
99     }
100 
101     # Compiler compilation debug info
102     # 0: Nothing printed out when compilation fails
103     # 1: Dump the graph out to repro.py if compilation fails
104     # 2: Dumps the graph out to minify_repro.py with a minifier if compilation fails
105     # 3: Always dumps the last graph ran out to minify_repro.py, useful for segfaults/irrecoverable errors
106     repro_level = int(os.environ.get("COMPILER_REPRO_LEVEL", 0))
107 
108     # Not all backends support scalars. Some calls on torch.Tensor (like .item()) return a scalar type.
109     # When this flag is set to False, we introduce a graph break instead of capturing.
110     capture_scalar_outputs = False
111 
112     def __setattr__(self, name, value):
113         if sys.version_info > (3, 8):
114             assert hasattr(
115                 self, name
116             ), f"Trying to set {name} - this value does not exist in torchdynamo.config"
117         object.__setattr__(self, name, value)
118 
119     def __delattr__(self, name):
120         if sys.version_info > (3, 8):
121             assert hasattr(
122                 self, name
123             ), f"Trying to del {name} - this value does not exist in torchdynamo.config"
124         object.__delattr__(self, name)
125 
126 
127 sys.modules[__name__] = AccessLimitingConfig("config")
128
```
--- 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/torchdynamo/config.py b/torchdynamo/config.py
--- a/torchdynamo/config.py
+++ b/torchdynamo/config.py
@@ -46,6 +46,8 @@
         torch.jit.is_scripting: False,
         torch.jit.is_tracing: False,
         torch._C._get_tracing_state: None,
+        torch.fx._symbolic_trace.is_fx_tracing: False,
+        torch.onnx.is_in_onnx_export: False,
     }
 
     # root folder of the project

{"golden_diff": "diff --git a/torchdynamo/config.py b/torchdynamo/config.py\n--- a/torchdynamo/config.py\n+++ b/torchdynamo/config.py\n@@ -46,6 +46,8 @@\n         torch.jit.is_scripting: False,\n         torch.jit.is_tracing: False,\n         torch._C._get_tracing_state: None,\n+        torch.fx._symbolic_trace.is_fx_tracing: False,\n+        torch.onnx.is_in_onnx_export: False,\n     }\n \n     # root folder of the project\n", "issue": "Dynamo WONT CONVERT for is_fx_tracing()\nProbably the same as #1009. Repro:\r\n```\r\nimport torchdynamo\r\nfrom torch.fx._symbolic_trace import is_fx_tracing\r\n\r\ndef my_compiler(gm, inputs):\r\n    return gm.forward\r\n\r\n@torchdynamo.optimize(my_compiler)\r\ndef fn(x, y):\r\n    if is_fx_tracing():\r\n        return x\r\n    else:\r\n        return y\r\n\r\nfn(1, 2)\r\n```\r\nreturns\r\n```\r\ntorchdynamo.convert_frame: [ERROR] WON'T CONVERT fn /private/home/suo/scratch/test.py line 8\r\ndue to:\r\nTraceback (most recent call last):\r\n  File \"/raid/suo/torchdynamo/torchdynamo/variables/tensor.py\", line 258, in create\r\n    assert (\r\nAssertionError: torch.* op returned non-Tensor bool call_function <function is_fx_tracing at 0x7f08b681e700>\r\n\r\nfrom user code:\r\n   File \"/private/home/suo/scratch/test.py\", line 10, in fn\r\n    if is_fx_tracing():\r\n\r\nSet torchdynamo.config.verbose=True for more information\r\n==========\r\n```\n", "before_files": [{"content": "import logging\nimport os\nimport sys\nfrom os.path import abspath\nfrom os.path import dirname\nfrom types import ModuleType\n\nimport torch\n\ntry:\n    import torch._prims\n    import torch._refs\n\n    HAS_REFS_PRIMS = True\nexcept ImportError:\n    HAS_REFS_PRIMS = False\n\n\nclass AccessLimitingConfig(ModuleType):\n    # log level (levels print what it says + all levels listed below it)\n    # DEBUG print full traces <-- lowest level + print tracing of every instruction\n    # INFO print compiled functions + graphs\n    # WARN print warnings (including graph breaks)\n    # ERROR print exceptions (and what user code was being processed when it occurred)\n    log_level = logging.WARNING\n    # Verbose will print full stack traces on warnings and errors\n    verbose = False\n\n    # verify the correctness of optimized backend\n    verify_correctness = False\n\n    # need this many ops to create an FX graph\n    minimum_call_count = 1\n\n    # turn on/off DCE pass\n    dead_code_elimination = True\n\n    # disable (for a function) when cache reaches this size\n    cache_size_limit = 64\n\n    # specializing int/float by default\n    specialize_int_float = True\n\n    # Assume these functions return constants\n    constant_functions = {\n        torch.jit.is_scripting: False,\n        torch.jit.is_tracing: False,\n        torch._C._get_tracing_state: None,\n    }\n\n    # root folder of the project\n    base_dir = dirname(dirname(abspath(__file__)))\n\n    # don't specialize on shapes and strides and put shape ops in graph\n    dynamic_shapes = os.environ.get(\"TORCHDYNAMO_DYNAMIC_SHAPES\") == \"1\"\n\n    # Set this to False to assume nn.Modules() contents are immutable (similar assumption as freezing)\n    guard_nn_modules = False\n\n    # Run the FX graph as it is created to get better type information\n    dynamic_propagation = True\n\n    # Run the FX graph with FakeTensors\n    fake_tensor_propagation = True\n\n    # run FX normalization passes in optimizer\n    normalize_ir = True\n\n    # If a tensor subclass type is in this set, torchdynamo will inline the\n    # __torch_function__ logic of the subclass.\n    traceable_tensor_subclasses = set()\n\n    # Raise torchdynamo internal assertions\n    raise_on_assertion_error = False\n\n    # Propagate backend exceptions up to torchdynamo.optimize\n    raise_on_backend_error = True\n\n    # If a PyTorch module is in this allowlist, torchdynamo will be allowed\n    # to inline objects from it or its children.\n    skipfiles_inline_module_allowlist = {torch.nn, torch.distributions}\n    if HAS_REFS_PRIMS:\n        skipfiles_inline_module_allowlist |= {\n            torch._refs,\n            torch._prims,\n            torch._decomp,\n        }\n\n    # If a string representing a PyTorch module is in this ignorelist,\n    # the `allowed_functions.is_allowed` function will not consider it\n    # when creating a list of PyTorch functions that will appear in\n    # FX IR.\n    allowed_functions_module_string_ignorelist = {\n        \"torch.distributions\",\n        \"torch.testing\",\n        \"torch._refs\",\n        \"torch._prims\",\n        \"torch._decomp\",\n    }\n\n    # Compiler compilation debug info\n    # 0: Nothing printed out when compilation fails\n    # 1: Dump the graph out to repro.py if compilation fails\n    # 2: Dumps the graph out to minify_repro.py with a minifier if compilation fails\n    # 3: Always dumps the last graph ran out to minify_repro.py, useful for segfaults/irrecoverable errors\n    repro_level = int(os.environ.get(\"COMPILER_REPRO_LEVEL\", 0))\n\n    # Not all backends support scalars. Some calls on torch.Tensor (like .item()) return a scalar type.\n    # When this flag is set to False, we introduce a graph break instead of capturing.\n    capture_scalar_outputs = False\n\n    def __setattr__(self, name, value):\n        if sys.version_info > (3, 8):\n            assert hasattr(\n                self, name\n            ), f\"Trying to set {name} - this value does not exist in torchdynamo.config\"\n        object.__setattr__(self, name, value)\n\n    def __delattr__(self, name):\n        if sys.version_info > (3, 8):\n            assert hasattr(\n                self, name\n            ), f\"Trying to del {name} - this value does not exist in torchdynamo.config\"\n        object.__delattr__(self, name)\n\n\nsys.modules[__name__] = AccessLimitingConfig(\"config\")\n", "path": "torchdynamo/config.py"}], "after_files": [{"content": "import logging\nimport os\nimport sys\nfrom os.path import abspath\nfrom os.path import dirname\nfrom types import ModuleType\n\nimport torch\n\ntry:\n    import torch._prims\n    import torch._refs\n\n    HAS_REFS_PRIMS = True\nexcept ImportError:\n    HAS_REFS_PRIMS = False\n\n\nclass AccessLimitingConfig(ModuleType):\n    # log level (levels print what it says + all levels listed below it)\n    # DEBUG print full traces <-- lowest level + print tracing of every instruction\n    # INFO print compiled functions + graphs\n    # WARN print warnings (including graph breaks)\n    # ERROR print exceptions (and what user code was being processed when it occurred)\n    log_level = logging.WARNING\n    # Verbose will print full stack traces on warnings and errors\n    verbose = False\n\n    # verify the correctness of optimized backend\n    verify_correctness = False\n\n    # need this many ops to create an FX graph\n    minimum_call_count = 1\n\n    # turn on/off DCE pass\n    dead_code_elimination = True\n\n    # disable (for a function) when cache reaches this size\n    cache_size_limit = 64\n\n    # specializing int/float by default\n    specialize_int_float = True\n\n    # Assume these functions return constants\n    constant_functions = {\n        torch.jit.is_scripting: False,\n        torch.jit.is_tracing: False,\n        torch._C._get_tracing_state: None,\n        torch.fx._symbolic_trace.is_fx_tracing: False,\n        torch.onnx.is_in_onnx_export: False,\n    }\n\n    # root folder of the project\n    base_dir = dirname(dirname(abspath(__file__)))\n\n    # don't specialize on shapes and strides and put shape ops in graph\n    dynamic_shapes = os.environ.get(\"TORCHDYNAMO_DYNAMIC_SHAPES\") == \"1\"\n\n    # Set this to False to assume nn.Modules() contents are immutable (similar assumption as freezing)\n    guard_nn_modules = False\n\n    # Run the FX graph as it is created to get better type information\n    dynamic_propagation = True\n\n    # Run the FX graph with FakeTensors\n    fake_tensor_propagation = True\n\n    # run FX normalization passes in optimizer\n    normalize_ir = True\n\n    # If a tensor subclass type is in this set, torchdynamo will inline the\n    # __torch_function__ logic of the subclass.\n    traceable_tensor_subclasses = set()\n\n    # Raise torchdynamo internal assertions\n    raise_on_assertion_error = False\n\n    # Propagate backend exceptions up to torchdynamo.optimize\n    raise_on_backend_error = True\n\n    # If a PyTorch module is in this allowlist, torchdynamo will be allowed\n    # to inline objects from it or its children.\n    skipfiles_inline_module_allowlist = {torch.nn, torch.distributions}\n    if HAS_REFS_PRIMS:\n        skipfiles_inline_module_allowlist |= {\n            torch._refs,\n            torch._prims,\n            torch._decomp,\n        }\n\n    # If a string representing a PyTorch module is in this ignorelist,\n    # the `allowed_functions.is_allowed` function will not consider it\n    # when creating a list of PyTorch functions that will appear in\n    # FX IR.\n    allowed_functions_module_string_ignorelist = {\n        \"torch.distributions\",\n        \"torch.testing\",\n        \"torch._refs\",\n        \"torch._prims\",\n        \"torch._decomp\",\n    }\n\n    # Compiler compilation debug info\n    # 0: Nothing printed out when compilation fails\n    # 1: Dump the graph out to repro.py if compilation fails\n    # 2: Dumps the graph out to minify_repro.py with a minifier if compilation fails\n    # 3: Always dumps the last graph ran out to minify_repro.py, useful for segfaults/irrecoverable errors\n    repro_level = int(os.environ.get(\"COMPILER_REPRO_LEVEL\", 0))\n\n    # Not all backends support scalars. Some calls on torch.Tensor (like .item()) return a scalar type.\n    # When this flag is set to False, we introduce a graph break instead of capturing.\n    capture_scalar_outputs = False\n\n    def __setattr__(self, name, value):\n        if sys.version_info > (3, 8):\n            assert hasattr(\n                self, name\n            ), f\"Trying to set {name} - this value does not exist in torchdynamo.config\"\n        object.__setattr__(self, name, value)\n\n    def __delattr__(self, name):\n        if sys.version_info > (3, 8):\n            assert hasattr(\n                self, name\n            ), f\"Trying to del {name} - this value does not exist in torchdynamo.config\"\n        object.__delattr__(self, name)\n\n\nsys.modules[__name__] = AccessLimitingConfig(\"config\")\n", "path": "torchdynamo/config.py"}]}