code: def create_groups(groups, k):
      """Bins sample indices with respect to groups, remove bins with less than k samples
  
      Args:
          groups (list[int]): where ith index stores ith sample's group id
  
      Returns:
          defaultdict[list]: Bins of sample indices, binned by group_idx
      """
      group_samples = defaultdict(list)
      for sample_idx, group_idx in enumerate(groups):
          group_samples[group_idx].append(sample_idx)
  
      keys_to_remove = []
      for key in group_samples:
          if len(group_samples[key]) < k:
              keys_to_remove.append(key)
              continue
  
      for key in keys_to_remove:
          group_samples.pop(key)
  
      return group_samples
  
file_path: vision/references/similarity/sampler.py
imports: import random
  from collections import defaultdict
  import torch
  from torch.utils.data.sampler import Sampler
label_desc: Use image node_id 1 for calling a global function with example usage: create_groups(groups, k) and returns: group_samples