  
          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
              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.
  
          Returns
          -------
          list:
              List of indices with the order implied by the hierarchical tree
 
</s> remove         Transforms a distance matrix into a sorted distance matrix according to the order implied
        by the hierarchical tree (dendrogram).
 </s> add 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
    """ </s> remove         Returns
        -------
        list:
            List of indices with the order implied by the hierarchical tree
        """
        logger.info("Sorting face distances. Depending on your dataset this may take some time...")
        num_predictions, dims = predictions.shape
 </s> add         self._should_output_bins = threshold is not None
        self._threshold = 0.0 if threshold is None else threshold
        self._bins: Dict[int, int] = {}
        self._iterator = self._integer_iterator() </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     def sorted_similarity(self, predictions, method="ward"):
        """ Sort a matrix of predictions by similarity.
 </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]
  
          Transforms a distance matrix into a sorted distance matrix according to the order implied
          by the hierarchical tree (dendrogram).
  
    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]
    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]
    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]
    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]
    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]
    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]
    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]
    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]
    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]
  
          Returns
          -------
          list:
              List of indices with the order implied by the hierarchical tree
keep keep keep keep replace replace replace replace replace replace replace 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