code: def relabel_groups_masked(group_idx, keep_group):
      
  
      keep_group = keep_group.astype(bool, copy=not keep_group[0])
      if not keep_group[0]:  # ensuring keep_group[0] is True makes life easier
          keep_group[0] = True
  
      relabel = np.zeros(keep_group.size, dtype=group_idx.dtype)
      relabel[keep_group] = np.arange(np.count_nonzero(keep_group))
      return relabel[group_idx]
docs: group_idx: [0 3 3 3 0 2 5 2 0 1 1 0 3 5 5]
     
                   0 1 2 3 4 5
      keep_group: [0 1 0 1 1 1]
      
      ret:       [0 2 2 2 0 0 4 0 0 1 1 0 2 4 4]
      
      Description of above in words: remove group 2, and relabel group 3,4, and 5
      to be 2, 3 and 4 respecitvely, in order to fill the gap.  Note that group 4 was never used
      in the input group_idx, but the user supplied mask said to keep group 4, so group
      5 is only moved up by one place to fill the gap created by removing group 2.
      
      That is, the mask describes which groups to remove,
      the remaining groups are relabled to remove the gaps created by the falsy
      elements in ``keep_group``.  Note that ``keep_group[0]`` has no particular meaning because it refers
      to the zero group which cannot be "removed".
  
      ``keep_group`` should be bool and ``group_idx`` int.
      Values in ``group_idx`` can be any order, and