class_docstr: Generates a pair of :class:`Checkpoint` and :class:`Recompute`.
class_docstr_tok: ["Generates","a","pair","of",":","class",":","`","Checkpoint","`","and",":","class",":","`","Recompute","`","."]
code: def __init__(self, function: Function, batch: Batch) -> None:
      self.function = function
      self.batch = batch
  
      # Shared memory between Checkpoint and Recompute. 1-length deque is
      # used for mutability and length limitation.
      self.recomputed: Deque[Recomputed] = deque(maxlen=1)
      self.rng_states: Deque[RNGStates] = deque(maxlen=1)
  
imports: from collections import deque
  from contextlib import contextmanager
  import threading
  from typing import TYPE_CHECKING, Deque, Generator, List, Optional, Tuple, Union
  import torch
  from torch import ByteTensor, Tensor
  import torch.autograd
  from .dependency import fork, join
  from .microbatch import Batch
  from .phony import get_phony
label_desc: Use image node_id 1 to create a new Checkpointing object  with example: obj = Checkpointing(function, batch)