def __sample_pos_neg(
        self,
        y_in: torch.Tensor,
        t_in: torch.Tensor,
        x_memory: torch.Tensor,
        y_memory: torch.Tensor,
        t_memory: torch.Tensor,
    ) -> tuple:
        """
        Method able to sample positive and negative examples with respect the input minibatch from input and buffer minibatches.
        :param x_in: Input of new minibatch.
        :param y_in: Output of new minibatch.
        :param t_in: Task ids of new minibatch.
        :param x_memory: Input of memory.
        :param y_memory: Output of minibatch.
        :param t_memory: Task ids of minibatch.
        :return: Tuple of positive and negative input and output examples and a mask for identify invalid values.
        """
        valid_pos = y_in.reshape(1, -1) == y_memory.reshape(-1, 1)
        if self.same_task_neg:
            same_task = t_in.view(1, -1) == t_memory.view(-1, 1)
            valid_neg = ~valid_pos & same_task
        else:
            valid_neg = ~valid_pos

        pos_idx = torch.multinomial(valid_pos.float().T, 1).squeeze(1)
        neg_idx = torch.multinomial(valid_neg.float().T, 1).squeeze(1)

        pos_x = x_memory[pos_idx]
        pos_y = y_memory[pos_idx]
        neg_x = x_memory[neg_idx]
        neg_y = y_memory[neg_idx]

        return pos_x, pos_y, neg_x, neg_y

        Method able to sample positive and negative examples with respect the input minibatch from input and buffer minibatches.
        :param x_in: Input of new minibatch.
        :param y_in: Output of new minibatch.
        :param t_in: Task ids of new minibatch.
        :param x_memory: Input of memory.
        :param y_memory: Output of minibatch.
        :param t_memory: Task ids of minibatch.
        :return: Tuple of positive and negative input and output examples and a mask for identify invalid values.
        
avalanche/training/regularization.py