code: def _gen_loop_end(
      chunk_inputs: List[Node],
      chunk_non_compute_inputs: List[Node],
      node_list: List[Node],
      chunk_outputs_idx: int,
      chunk_outputs_non_tensor: List[Node],
      search_chunk: SearchChunk,
  ) -> str:
      """
      Generate chunk loop end
  
      eg.     chunk_result[chunk_idx:chunk_idx + chunk_size] = output_node
          output_node = chunk_result; xx = None; xx = None
  
      Args:
          chunk_inputs (List[Node]): chunk input node
          chunk_non_compute_inputs (List[Node]): input node without chunk
          chunk_outputs (Node): chunk output node
          chunk_outputs_dim (int): chunk output node chunk dim
          node_list (List)
  
      Returns:
          context (str): generated str
      """
      context = "chunk_size = None"
      # determine if its the last use for chunk input
      for chunk_input in chunk_inputs + chunk_non_compute_inputs:
          if all(
              [
                  search_chunk.node_mgr.find_node_idx(user)
                  <= chunk_outputs_idx
                  for user in chunk_input.users.keys()
              ]
          ):
              context += ";  %s = None" % chunk_input.name
      for (
          chunk_output_non_tensor,
          chunk_output_non_tensor_val,
      ) in chunk_outputs_non_tensor.items():
          context += ";  %s = %s" % (
              chunk_output_non_tensor.name,
              chunk_output_non_tensor_val,
          )
      context += "\n"
      return context
  
file_path: ColossalAI/colossalai/autochunk/autochunk_codegen.py
imports: from typing import Any, Callable, Dict, Iterable, List, Tuple
  import torch
  import colossalai
  from colossalai.fx._compatibility import is_compatible_with_meta
  from colossalai.fx.codegen.activation_checkpoint_codegen import CODEGEN_AVAILABLE
  from torch.fx.node import Argument, Node, _get_qualified_name, _type_repr, map_arg
  from .search_chunk import SearchChunk
  from .utils import delete_free_var_from_last_use, get_logger, get_node_name, get_node_shape
label_desc: Use image node_id 3 for calling a global function with example usage: _gen_loop_end(chunk_inputs, chunk_non_compute_inputs, node_list, chunk_outputs_idx, chunk_outputs_non_tensor, search_chunk) and returns: context