  
      def sorted_similarity(self, predictions, method="ward"):
          """ Sort a matrix of predictions by similarity.
  
          Transforms a distance matrix into a sorted distance matrix according to the order implied
          by the hierarchical tree (dendrogram).
  
          Parameters
          ----------
          predictions: numpy.ndarray
              A stacked matrix of vgg_face2 predictions of the shape (`N`, `D`) where `N` is the
 
</s> remove         Parameters
        ----------
        predictions: numpy.ndarray
            A stacked matrix of vgg_face2 predictions of the shape (`N`, `D`) where `N` is the
            number of observations and `D` are the number of dimensions.  NB: The given
            :attr:`predictions` will be overwritten to save memory. If you still require the
            original values you should take a copy prior to running this method
        method: ['single','centroid','median','ward']
            The clustering method to use.
 </s> add     def __init__(self,
                 predictions: np.ndarray,
                 method: Literal["single", "centroid", "median", "ward"],
                 threshold: Optional[float] = None) -> None:
        logger.debug("Initializing: %s (predictions: %s, method: %s, threshold: %s)",
                     self.__class__.__name__, predictions.shape, method, threshold)
        self._num_predictions = predictions.shape[0] </s> remove     def sorted_similarity(self, predictions, method="ward"):
        """ Sort a matrix of predictions by similarity.
 </s> add  </s> remove     def _seriation(self, tree, points, current_index):
 </s> add     def _do_linkage(self,
                    predictions: np.ndarray,
                    method: Literal["single", "centroid", "median", "ward"]) -> np.ndarray:
        """ Use FastCluster to perform vector or standard linkage

        Parameters
        ----------
        predictions: :class:`numpy.ndarray`
            A stacked matrix of vgg_face2 predictions of the shape (`N`, `D`) where `N` is the
            number of observations and `D` are the number of dimensions.
        method: ['single','centroid','median','ward']
            The clustering method to use.

        Returns
        -------
        :class:`numpy.ndarray`
            The [`num_predictions`, 4] linkage vector
        """
        dims = predictions.shape[-1]
        if self._use_vector_linkage(dims):
            retval = linkage_vector(predictions, method=method)
        else:
            retval = linkage(predictions, method=method, preserve_input=False)
        logger.debug("Linkage shape: %s", retval.shape)
        return retval

    def _process_leaf_node(self,
                           current_index: int,
                           current_bin: int) -> List[Tuple[int, int]]:
        """ Process the output when we have hit a leaf node """
        if not self._should_output_bins:
            return [(current_index, 0)]

        if current_bin not in self._bins:
            next_val = 0 if not self._bins else max(self._bins.values()) + 1
            self._bins[current_bin] = next_val
        return [(current_index, self._bins[current_bin])]

    def _get_bin(self,
                 tree: np.ndarray,
                 points: int,
                 current_index: int,
                 current_bin: int) -> int:
        """ Obtain the bin that we are currently in.

        If we are not currently below the threshold for binning, get a new bin ID from the integer
        iterator.

        Parameters
        ----------
        tree: numpy.ndarray
           A hierarchical tree (dendrogram)
        points: int
            The number of points given to the clustering process
        current_index: int
            The position in the tree for the recursive traversal
        current_bin int, optional
            The ID for the bin we are currently in. Only used when binning is enabled

        Returns
        -------
        int
            The current bin ID for the node
        """
        if tree[current_index - points, 2] >= self._threshold:
            current_bin = next(self._iterator)
            logger.debug("Creating new bin ID: %s", current_bin)
        return current_bin

    def _seriation(self,
                   tree: np.ndarray,
                   points: int,
                   current_index: int,
                   current_bin: int = 0) -> List[Tuple[int, int]]: </s> remove             help=_("R|Sort by method. Choose how images are sorted. "
                   "\nL|'blur': Sort faces by blurriness."
                   "\nL|'blur-fft': Sort faces by fft filtered blurriness."
                   "\nL|'distance' Sort faces by the estimated distance of the alignments from an "
                   "'average' face. This can be useful for eliminating misaligned faces."
                   "\nL|'face': Use VGG Face to sort by face similarity. This uses a pairwise "
                   "clustering algorithm to check the distances between 512 features on every "
                   "face in your set and order them appropriately."
                   "\nL|'face-cnn': Sort faces by their landmarks. You can adjust the threshold "
                   "with the '-t' (--ref_threshold) option."
                   "\nL|'face-cnn-dissim': Like 'face-cnn' but sorts by dissimilarity."
                   "\nL|'face-yaw': Sort faces by Yaw (rotation left to right)."
                   "\nL|'hist': Sort faces by their color histogram. You can adjust the threshold "
                   "with the '-t' (--ref_threshold) option."
                   "\nL|'hist-dissim': Like 'hist' but sorts by dissimilarity."
                   "\nL|'color-gray': Sort images by the average intensity of the converted "
                   "grayscale color channel."
                   "\nL|'color-luma': Sort images by the average intensity of the converted Y "
                   "color channel. Bright lighting and oversaturated images will be ranked first."
                   "\nL|'color-green': Sort images by the average intensity of the converted Cg "
                   "color channel. Green images will be ranked first and red images will be last."
                   "\nL|'color-orange': Sort images by the average intensity of the converted Co "
                   "color channel. Orange images will be ranked first and blue images will be "
                   "last."
                   "\nL|'size': Sort images by their size in the original frame. Faces closer to "
                   "the camera and from higher resolution sources will be sorted first, whilst "
                   "faces further from the camera and from lower resolution sources will be "
                   "sorted last."
                   "\nL|'black-pixels': Sort images by their number of black pixels. Useful when "
                   "faces are near borders and a large part of the image is black."
 </s> add             help=_("R|Choose how images are sorted. Selecting a sort method gives the images a "
                   "new filename based on the order the image appears within the given method."
                   "\nL|'none': Don't sort the images. When a 'group-by' method is selected, "
                   "selecting 'none' means that the files will be moved/copied into their "
                   "respective bins, but the files will keep their original filenames. Selecting "
                   "'none' for both 'sort-by' and 'group-by' will do nothing" + _SORT_HELP +
class Cluster():  # pylint: disable=too-few-public-methods
    """ Cluster the outputs from a VGG-Face 2 Model

    Parameters
    ----------
    predictions: numpy.ndarray
        A stacked matrix of vgg_face2 predictions of the shape (`N`, `D`) where `N` is the
        number of observations and `D` are the number of dimensions.  NB: The given
        :attr:`predictions` will be overwritten to save memory. If you still require the
        original values you should take a copy prior to running this method
    method: ['single','centroid','median','ward']
        The clustering method to use.
    threshold: float, optional
        The threshold to start creating bins for. Set to ``None`` to disable binning
    """
  
      def sorted_similarity(self, predictions, method="ward"):
          """ Sort a matrix of predictions by similarity.
  
class Cluster():  # pylint: disable=too-few-public-methods
    """ Cluster the outputs from a VGG-Face 2 Model

    Parameters
    ----------
    predictions: numpy.ndarray
        A stacked matrix of vgg_face2 predictions of the shape (`N`, `D`) where `N` is the
        number of observations and `D` are the number of dimensions.  NB: The given
        :attr:`predictions` will be overwritten to save memory. If you still require the
        original values you should take a copy prior to running this method
    method: ['single','centroid','median','ward']
        The clustering method to use.
    threshold: float, optional
        The threshold to start creating bins for. Set to ``None`` to disable binning
    """
class Cluster():  # pylint: disable=too-few-public-methods
    """ Cluster the outputs from a VGG-Face 2 Model

    Parameters
    ----------
    predictions: numpy.ndarray
        A stacked matrix of vgg_face2 predictions of the shape (`N`, `D`) where `N` is the
        number of observations and `D` are the number of dimensions.  NB: The given
        :attr:`predictions` will be overwritten to save memory. If you still require the
        original values you should take a copy prior to running this method
    method: ['single','centroid','median','ward']
        The clustering method to use.
    threshold: float, optional
        The threshold to start creating bins for. Set to ``None`` to disable binning
    """
  
          Parameters
          ----------
          predictions: numpy.ndarray
              A stacked matrix of vgg_face2 predictions of the shape (`N`, `D`) where `N` is the
keep keep keep keep replace replace keep keep keep keep keep
 Overhaul sort:
  - Standardize image data reading and writing
  - Optimize loading (just one pass required)
  - Make all sort groups binnable (to greater or lesser results)
  - Add sort by pitch
  - Deprecate multiple options
  - linting, docs + locales 
plugins/extract/recognition/vgg_face2_keras.py