code: def _gen_saved_tensors_hooks():
      """
      Generate saved tensors hooks
      """
  
      pack_hook = """def pack_hook_input(self, x):
      if getattr(x, "offload", False):
          return (x.device, x.cpu())
      else:
          return x
  
  def pack_hook_no_input(self, x):
      if getattr(x, "offload", True):
          return (x.device, x.cpu())
      else:
          return x
  """
  
      unpack_hook = """def unpack_hook(self, packed):
      if isinstance(packed, tuple):
          device, tensor = packed
          return tensor.to(device)
      else:
          return packed
  """
  
      return pack_hook, unpack_hook
  
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 1 for calling a global function with example usage: _gen_saved_tensors_hooks() and returns: pack_hook,  unpack_hook