code: def __init__(self, *, encoder, masking_ratio=0.5):
      super().__init__()
      assert (
          masking_ratio > 0 and masking_ratio < 1
      ), "masking ratio must be kept between 0 and 1"
      self.masking_ratio = masking_ratio
  
      # extract some hyperparameters and functions from encoder (vision transformer to be trained)
  
      self.encoder = encoder
      num_patches, encoder_dim = encoder.pos_embedding.shape[-2:]
  
      self.to_patch = encoder.to_patch_embedding[0]
      self.patch_to_emb = nn.Sequential(*encoder.to_patch_embedding[1:])
  
      pixel_values_per_patch = encoder.to_patch_embedding[
          2
      ].weight.shape[-1]
  
      # simple linear head
  
      self.mask_token = nn.Parameter(torch.randn(encoder_dim))
      self.to_pixels = nn.Linear(encoder_dim, pixel_values_per_patch)
  
file_path: vit-pytorch/vit_pytorch/simmim.py
imports: import torch
  from torch import nn
  import torch.nn.functional
  from einops import repeat
label_desc: Use image node_id 1 to create a new SimMIM object from inherited base classes: nn with example: obj = SimMIM()