class_docstr: Transforms control flow structures like loops an conditionals.
class_docstr_tok: ["Transforms","control","flow","structures","like","loops","an","conditionals","."]
code: def visit_If(self, node):
      node = self.generic_visit(node)
      body_scope = anno.getanno(node, annos.NodeAnno.BODY_SCOPE)
      orelse_scope = anno.getanno(node, annos.NodeAnno.ORELSE_SCOPE)
  
      cond_vars, undefined, nouts = self._get_block_vars(
          node, body_scope.bound | orelse_scope.bound
      )
  
      undefined_assigns = self._create_undefined_assigns(undefined)
  
      nonlocal_declarations = self._create_nonlocal_declarations(
          cond_vars
      )
  
      reserved = body_scope.referenced | orelse_scope.referenced
      state_getter_name = self.ctx.namer.new_symbol(
          "get_state", reserved
      )
      state_setter_name = self.ctx.namer.new_symbol(
          "set_state", reserved
      )
      state_functions = self._create_state_functions(
          cond_vars,
          nonlocal_declarations,
          state_getter_name,
          state_setter_name,
      )
  
      orelse_body = node.orelse
      if not orelse_body:
          orelse_body = [gast.Pass()]
  
      template = """
        state_functions
        def body_name():
          nonlocal_declarations
          body
        def orelse_name():
          nonlocal_declarations
          orelse
        undefined_assigns
        ag__.if_stmt(
          test,
          body_name,
          orelse_name,
          state_getter_name,
          state_setter_name,
          (symbol_names,),
          nouts)
      """
      new_nodes = templates.replace(
          template,
          body=node.body,
          body_name=self.ctx.namer.new_symbol("if_body", reserved),
          orelse=orelse_body,
          orelse_name=self.ctx.namer.new_symbol("else_body", reserved),
          nonlocal_declarations=nonlocal_declarations,
          nouts=gast.Constant(nouts, kind=None),
          state_functions=state_functions,
          state_getter_name=state_getter_name,
          state_setter_name=state_setter_name,
          symbol_names=tuple(
              gast.Constant(str(s), kind=None) for s in cond_vars
          ),
          test=node.test,
          undefined_assigns=undefined_assigns,
      )
      origin_info.copy_origin(node, new_nodes[-1])
      return new_nodes
  
imports: import gast
  from tensorflow.python.autograph.core import converter
  from tensorflow.python.autograph.lang import directives
  from tensorflow.python.autograph.pyct import anno
  from tensorflow.python.autograph.pyct import cfg
  from tensorflow.python.autograph.pyct import origin_info
  from tensorflow.python.autograph.pyct import parser
  from tensorflow.python.autograph.pyct import qual_names
  from tensorflow.python.autograph.pyct import templates
  from tensorflow.python.autograph.pyct.static_analysis import activity
  from tensorflow.python.autograph.pyct.static_analysis import annos
  from tensorflow.python.autograph.pyct.static_analysis import liveness
  from tensorflow.python.autograph.pyct.static_analysis import reaching_definitions
  from tensorflow.python.autograph.pyct.static_analysis import reaching_fndefs
label_desc: Use image node_id 10 for calling the ControlFlowTransformer obj's underlying member method code with example usage: obj.visit_If(node) and returns: new_nodes