class_docstr: Replace AST nodes.
class_docstr_tok: ["Replace","AST","nodes","."]
docstr: Prepares a replacement AST that's safe to swap in for a node.
  
  Args:
    replaced: ast.AST, the node being replaced
    key: Hashable, the key of the replacement AST
  Returns:
    ast.AST, the replacement AST
docstr_tok: ["Prepares","a","replacement","AST","that","'s","safe","to","swap","in","for","a","node",".","Args",":","replaced",":","ast.AST",",","the","node","being","replaced","key",":","Hashable",",","the","key","of","the","replacement","AST","Returns",":","ast.AST",",","the","replacement","AST"]
code: def _prepare_replacement(self, replaced, key):
      """Prepares a replacement AST that's safe to swap in for a node.
  
      Args:
        replaced: ast.AST, the node being replaced
        key: Hashable, the key of the replacement AST
      Returns:
        ast.AST, the replacement AST
      """
      repl = self.replacements[key]
  
      new_nodes = ast_util.copy_clean(
          repl, preserve_annos=self.preserved_annos
      )
      if isinstance(new_nodes, gast.AST):
          new_nodes = [new_nodes]
  
      return new_nodes
  
imports: import ast
  import textwrap
  import gast
  from nvidia.dali._autograph.pyct import anno
  from nvidia.dali._autograph.pyct import ast_util
  from nvidia.dali._autograph.pyct import parser
  from nvidia.dali._autograph.pyct import qual_names
label_desc: Use image node_id 2 for calling the ReplaceTransformer obj's underlying member method code with example usage: obj._prepare_replacement(replaced, key) and returns: new_nodes