class_docstr: Take a FunctionType object representing a `forward` method, then
  perform an AST rewrite to swap out nodes that are not symbolically
  traceable with a callsite to the FX alternative.
  
  To support swapping out an AST node, define a new `visit` method on
  that node. For more details, see:
  https://docs.python.org/3/library/ast.html#ast.NodeTransformer
class_docstr_tok: ["Take","a","FunctionType","object","representing","a","`","forward","`","method",",","then","perform","an","AST","rewrite","to","swap","out","nodes","that","are","not","symbolically","traceable","with","a","callsite","to","the","FX","alternative",".","To","support","swapping","out","an","AST","node",",","define","a","new","`","visit","`","method","on","that","node",".","For","more","details",",","see",":","https",":","\/\/docs.python.org\/3\/library\/ast.html","#","ast.NodeTransformer"]
docstr: Swap out the Assert node (Python's `assert`) with a callsite to the
  symbolically-traceable torch._assert function
docstr_tok: ["Swap","out","the","Assert","node","(","Python","'s","`","assert","`",")","with","a","callsite","to","the","symbolically-traceable","torch._assert","function"]
code: def visit_Assert(self, node):
      """
      Swap out the Assert node (Python's `assert`) with a callsite to the
      symbolically-traceable torch._assert function
      """
      # Create the Call node
      n = ast.parse("torch._assert()", mode="eval")
      assert isinstance(n, ast.Expression)
      call_node = n.body
      assert isinstance(call_node, ast.Call)
      msg = node.msg if node.msg else ast.Constant(value="", kind=None)
      call_node.args = [node.test, msg]
  
      # Ensure that the new node conforms to the Python AST grammar
      expr_wrapper = ast.Expr(value=call_node)
  
      # Return the new Call node to signify that we want to use it as
      # a replacement for the original _assert node
      return ast.copy_location(expr_wrapper, node)
  
file_path: pytorch/torch/fx/experimental/rewriter.py
imports: import ast
  import inspect
  import textwrap
  import copy
  import functools
  from types import FunctionType
  from typing import cast, Union, Callable, Dict, Optional, Any
  from torch.fx._symbolic_trace import Tracer
  from torch.fx.graph import Graph
  from torch._sources import normalize_source_lines
  import torch
label_desc: Use image node_id 2 for calling the AST_Rewriter obj's underlying member method code with example usage: obj.visit_Assert(node) and returns: ast