class_docstr: Generates a pair of :class:`Checkpoint` and :class:`Recompute`.
class_docstr_tok: ["Generates","a","pair","of",":","class",":","`","Checkpoint","`","and",":","class",":","`","Recompute","`","."]
docstr: Applies :class:`Recompute` to the batch in place.
docstr_tok: ["Applies",":","class",":","`","Recompute","`","to","the","batch","in","place","."]
code: def recompute(self, batch: Batch) -> None:
      """Applies :class:`Recompute` to the batch in place."""
      input_atomic = self.batch.atomic
      input = tuple(self.batch)
  
      # batch[0] is always requiring grad, because it has been passed
      # checkpoint with a phony requiring grad.
      batch[0], phony = fork(batch[0])
      phony = Recompute.apply(
          phony,
          self.recomputed,
          self.rng_states,
          self.function,
          input_atomic,
          *input,
      )
      batch[0] = join(batch[0], phony)
  
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 3 for calling the Checkpointing obj's underlying member method code with example usage: obj.recompute(batch) without return types