code: def create_mask(
      high: int,
      mask_shape: Tuple[int, int],
      log_aspect_ratio: Tuple[float, float],
  ) -> torch.Tensor:
      """Create a mask for the global view
      Copy-pasted and adapted from iBOT (https://arxiv.org/pdf/2111.07832.pdf) official code:
      https://github.com/bytedance/ibot/blob/da316d82636a7a7356835ef224b13d5f3ace0489/loader.py#L67
      """
      H, W = mask_shape
      mask = np.zeros(mask_shape, dtype=bool)
      mask_count = 0
      while mask_count < high:
          max_mask_patches = high - mask_count
  
          delta = 0
          for _attempt in range(10):
              low = (min(mask_shape) // 3) ** 2
              target_area = random.uniform(low, max_mask_patches)
              aspect_ratio = math.exp(random.uniform(*log_aspect_ratio))
              h = int(round(math.sqrt(target_area * aspect_ratio)))
              w = int(round(math.sqrt(target_area / aspect_ratio)))
              if w < W and h < H:
                  top = random.randint(0, H - h)
                  left = random.randint(0, W - w)
  
                  num_masked = mask[
                      top : top + h, left : left + w
                  ].sum()
                  if 0 < h * w - num_masked <= max_mask_patches:
                      for i in range(top, top + h):
                          for j in range(left, left + w):
                              if mask[i, j] == 0:
                                  mask[i, j] = 1
                                  delta += 1
  
              if delta > 0:
                  break
  
          if delta == 0:
              break
          else:
              mask_count += delta
  
      return torch.from_numpy(mask)
  
file_path: vissl/vissl/data/ssl_transforms/masked_image_modeling.py
imports: import math
  import random
  from typing import Any, Dict, List, Tuple
  import numpy
  import torch
  from classy_vision.dataset.transforms import register_transform
  from classy_vision.dataset.transforms.classy_transform import ClassyTransform
label_desc: Use image node_id 2 for calling a global function with example usage: create_mask(high, mask_shape, log_aspect_ratio) and returns: torch