docstr: The chain is a basic linearized structure for solving the dynamic programming problem for activation checkpoint.
  See paper https://hal.inria.fr/hal-02352969 for details.
  
  Args:
      ftime (List[float]): The forward time of each node.
      btime (List[float]): The backward time of each node.
      x (List[int]): The forward memory of each node (if save_output). Same as `a` in the paper.
      xbar (List[int]): The forward memory of each node (if save_all). Same as `a_bar` in the paper.
      ftmp (List[int]): The temporary forward memory of each node.
      btmp (List[int]): The temporary backward memory of each node, can be used to control memory budget.
      check_consistency (bool, optional): Check the lengths consistency for the `Chain`. Defaults to True.
code: def __init__(
      self,
      ftime: List[float],
      btime: List[float],
      x: List[int],
      xbar: List[int],
      ftmp: List[int],
      btmp: List[int],
      check_consistency: bool = True,
  ):
      """The chain is a basic linearized structure for solving the dynamic programming problem for activation checkpoint.
      See paper https://hal.inria.fr/hal-02352969 for details.
  
      Args:
          ftime (List[float]): The forward time of each node.
          btime (List[float]): The backward time of each node.
          x (List[int]): The forward memory of each node (if save_output). Same as `a` in the paper.
          xbar (List[int]): The forward memory of each node (if save_all). Same as `a_bar` in the paper.
          ftmp (List[int]): The temporary forward memory of each node.
          btmp (List[int]): The temporary backward memory of each node, can be used to control memory budget.
          check_consistency (bool, optional): Check the lengths consistency for the `Chain`. Defaults to True.
      """
      self.ftime = ftime
      self.btime = btime
      self.x = x
      self.xbar = xbar
      self.ftmp = ftmp
      self.btmp = btmp
      if check_consistency and not self.check_lengths():
          raise AttributeError(
              "In Chain, input lists do not have consistent lengths"
          )
  
imports: import math
  from abc import ABC
  from typing import List
  from torch.utils._pytree import tree_map
label_desc: Use image node_id 1 to create a new Chain object  with example: obj = Chain(ftime, btime, x, xbar, ftmp, btmp, check_consistency)