code: def emit_code_with_activation_checkpoint(
      body, ckpt_func, nodes, emit_node_func, delete_unused_value_func
  ):
      """Emit code with nested activation checkpoint
      When we detect some of the annotation is a , we will use
      this function to emit the activation checkpoint codes.
  
      Args:
          body: forward code
          ckpt_func: checkpoint functions code
          nodes: graph.nodes
          emit_node_func: function to emit node
          delete_unused_value_func: function to remove the unused value
      """
      ckpt_regions = _find_nested_ckpt_regions(nodes, 0)
      start_idx = [item[0] for item in ckpt_regions]
      end_idx = [item[1] for item in ckpt_regions]
      node_list = list(nodes)
  
      node_idx = 0
      while 1:
          # break if we finish the processing all the nodes
          if node_idx >= len(node_list):
              break
  
          # process ckpt_regions
          if node_idx in start_idx:
              ckpt_node_list = node_list[
                  node_idx : end_idx[start_idx.index(node_idx)] + 1
              ]
              emit_ckpt_func(
                  body,
                  ckpt_func,
                  ckpt_node_list,
                  emit_node_func,
                  delete_unused_value_func,
              )
              node_idx += len(ckpt_node_list)
  
          # process node in forward function
          else:
              node = node_list[node_idx]
              emit_node_func(node, body)
              delete_unused_value_func(node, body)
              node_idx += 1
  
file_path: colossalai/colossalai/_analyzer/fx/codegen.py
imports: from typing import Any, Dict, List, Tuple
  import torch
  from torch.fx.graph import PythonCode, _custom_builtins, _format_target, _is_from_torch, _Namespace, _origin_type_map, _register_custom_builtin, inplace_methods, magic_methods
  from torch.fx.node import Argument, Node, _get_qualified_name, _type_repr, map_arg
  import colossalai
  from colossalai.fx._compatibility import compatibility
label_desc: Use image node_id 8 for calling a global function with example usage: emit_code_with_activation_checkpoint(body, ckpt_func, nodes, emit_node_func, delete_unused_value_func) without return types