code: def _getCellsWithFewestSegments(self, columns):
      
      candidateCells = np2.getAllCellsInColumns(columns, self.cellsPerColumn)
  
      # Arrange the segment counts into one row per minicolumn.
      segmentCounts = np.reshape(
        self.basalConnections.getSegmentCounts(candidateCells) +
        self.apicalConnections.getSegmentCounts(candidateCells),
        newshape=(len(columns),
                  self.cellsPerColumn))
  
      # Filter to just the cells that are tied for fewest in their minicolumn.
      minSegmentCounts = np.amin(segmentCounts, axis=1, keepdims=True)
      candidateCells = candidateCells[np.flatnonzero(segmentCounts ==
                                                     minSegmentCounts)]
  
      # Filter to one cell per column, choosing randomly from the minimums.
      # To do the random choice, add a random offset to each index in-place, using
      # casting to floor the result.
      (_,
       onePerColumnFilter,
       numCandidatesInColumns) = np.unique(candidateCells / self.cellsPerColumn,
                                           return_index=True, return_counts=True)
  
      offsetPercents = np.empty(len(columns), dtype="float32")
      self.rng.initializeReal32Array(offsetPercents)
  
      np.add(onePerColumnFilter,
             offsetPercents*numCandidatesInColumns,
             out=onePerColumnFilter,
             casting="unsafe")
  
      return candidateCells[onePerColumnFilter]
docs: For each column, get the cell that has the fewest total segments (basal or
      apical). Break ties randomly.
  
      @param columns (numpy array)
      Columns to check
  
      @return (numpy array)
      One cell for each of the provided columns