class_docstr: Reversible Blocks for Reversible Vision Transformer and also
  for state-preserving blocks in Reversible MViT. See Section
  3.3.2 in paper for details.
class_docstr_tok: ["Reversible","Blocks","for","Reversible","Vision","Transformer","and","also","for","state-preserving","blocks","in","Reversible","MViT",".","See","Section","3.3.2","in","paper","for","details","."]
docstr: Fix seeds to allow for stochastic elements such as
  dropout to be reproduced exactly in activation
  recomputation in the backward pass.
docstr_tok: ["Fix","seeds","to","allow","for","stochastic","elements","such","as","dropout","to","be","reproduced","exactly","in","activation","recomputation","in","the","backward","pass","."]
code: def seed_cuda(self, key):
      """
      Fix seeds to allow for stochastic elements such as
      dropout to be reproduced exactly in activation
      recomputation in the backward pass.
      """
  
      # randomize seeds
      # use cuda generator if available
      if (
          hasattr(torch.cuda, "default_generators")
          and len(torch.cuda.default_generators) > 0
      ):
          # GPU
          device_idx = torch.cuda.current_device()
          seed = torch.cuda.default_generators[device_idx].seed()
      else:
          # CPU
          seed = int(torch.seed() % sys.maxsize)
  
      self.seeds[key] = seed
      torch.manual_seed(self.seeds[key])
  
imports: import sys
  from functools import partial
  import torch
  from torch import nn
  from torch.autograd import Function
  from slowfast.models.attention import MultiScaleAttention, attention_pool
  from slowfast.models.common import Mlp, TwoStreamFusion, drop_path
  from slowfast.models.utils import round_width
label_desc: Use image node_id 2 for calling the ReversibleBlock obj's underlying member method code with example usage: obj.seed_cuda(key) without return types