class_docstr: Functor for translating Relay programs into Python ASTs.
class_docstr_tok: ["Functor","for","translating","Relay","programs","into","Python","ASTs","."]
docstr: For writing refs, we wrap the update in a thunk
  (returning an empty tuple to match Relay's semantics)
  that we execute at the right time. This ensures such assignments
  can be properly nested, since assignments are statements
  in Python but expressions in Relay
docstr_tok: ["For","writing","refs",",","we","wrap","the","update","in","a","thunk","(","returning","an","empty","tuple","to","match","Relay","'s","semantics",")","that","we","execute","at","the","right","time",".","This","ensures","such","assignments","can","be","properly","nested",",","since","assignments","are","statements","in","Python","but","expressions","in","Relay"]
code: def visit_ref_write(self, write: Expr):
      """For writing refs, we wrap the update in a thunk
      (returning an empty tuple to match Relay's semantics)
      that we execute at the right time. This ensures such assignments
      can be properly nested, since assignments are statements
      in Python but expressions in Relay"""
      ref, ref_defs = self.visit(write.ref)
      val, val_defs = self.visit(write.value)
      thunk_name = self.generate_function_name("_ref_write_thunk")
      thunk = self.create_def(
          thunk_name,
          [],
          ref_defs
          + val_defs
          + [
              Assign([ast.Attribute(ref, "value", Store())], val),
              Return(self.create_tuple([])),
          ],
      )
      return (self.create_call(thunk_name, []), [thunk])
  
imports: import sys
  import ast
  from ast import alias, Assign, Load, Name, NameConstant, Num, Return, Store, Str
  import re
  import tvm
  from tvm import relay
  from tvm.relay.adt import Pattern
  from tvm.relay.backend import te_compiler
  from tvm.relay.expr import Expr, GlobalVar, Var
  from tvm.relay.function import Function
  from tvm.relay.expr_functor import ExprFunctor
label_desc: Use image node_id 32 for calling the PythonConverter obj's underlying member method code with example usage: obj.visit_ref_write(write) and returns: self,  list