code: def where(self, within_of=None, inplace=False, **kwargs):
          
          masks = super(System, self).where(inplace=inplace, **kwargs)
          
          def index_to_mask(index, n):
              val = np.zeros(n, dtype='bool')
              val[index] = True
              return val
          
          def masks_and(dict1, dict2):
              return {k: dict1[k] & index_to_mask(dict2[k], len(dict1[k])) for k in dict1 }
          
          if within_of is not None:
              if self.box_vectors is None:
                  raise Exception('Only periodic distance supported')
              thr, ref = within_of
              
              if isinstance(ref, int):
                  a = self.r_array[ref][np.newaxis, np.newaxis, :] # (1, 1, 3,)
              elif len(ref) == 1:
                  a = self.r_array[ref][np.newaxis, :] # (1, 1, 3)
              else:
                  a = self.r_array[ref][:, np.newaxis, :] # (2, 1, 3)
              
              b = self.r_array[np.newaxis, :, :]
              dist = periodic_distance(a, b,
                                       periodic=self.box_vectors.diagonal())
              
              atoms = (dist <= thr).sum(axis=0, dtype='bool')
              m = self._propagate_dim(atoms, 'atom')
              masks = masks_and(masks, m)
          
          return masks
docs: Return indices that met the conditions