code: def _find_offload_regions(nodes: List[Node]):
      """This function is to find the offload regions
      In pofo algorithm, during annotation, we will annotate the offload region with the
      list in the form of [idx, offload_input, offload_bar]. idx indicates the offload
      region's index, offload_input is a bool type indicates whether we need to offload
      the input, offload_bar is a bool type indicates whether we need to offload all the
      intermediate x_bars of this region.
      """
      offload_regions = []
      offload_labels = []
      start = -1
      end = -1
      current_region = None
  
      for idx, node in enumerate(nodes):
          if "activation_offload" in node.meta and isinstance(
              node.meta["activation_offload"], Iterable
          ):
              act_offload_label = node.meta["activation_offload"]
  
              if current_region == None:
                  current_region = act_offload_label
                  start = idx
                  offload_labels.append(act_offload_label)
  
              if act_offload_label != current_region:
                  assert start != -1
                  offload_regions.append((start, idx - 1))
                  offload_labels.append(act_offload_label)
                  current_region = act_offload_label
                  start = idx
                  end = -1
  
          else:
              if current_region is not None:
                  end = idx - 1
                  assert start != -1 and end != -1
                  offload_regions.append((start, end))
                  start = end = -1
                  current_region = None
  
              else:
                  pass
  
      return offload_regions, offload_labels
  
file_path: ColossalAI/colossalai/fx/codegen/activation_checkpoint_codegen.py
imports: from typing import Any, Dict, Iterable, List, Tuple
  import torch
  import colossalai
label_desc: Use image node_id 6 for calling a global function with example usage: _find_offload_regions(nodes) and returns: offload_regions,  offload_labels