code: def fast_PLDA_scoring(
      enroll,
      test,
      ndx,
      mu,
      F,
      Sigma,
      test_uncertainty=None,
      Vtrans=None,
      p_known=0.0,
      scaling_factor=1.0,
      check_missing=True,
  ):
      """Compute the PLDA scores between to sets of vectors. The list of
      trials to perform is given in an Ndx object. PLDA matrices have to be
      pre-computed. i-vectors/x-vectors are supposed to be whitened before.
  
      Arguments
      ---------
      enroll : speechbrain.utils.Xvector_PLDA_sp.StatObject_SB
          A StatServer in which stat1 are xvectors.
      test : speechbrain.utils.Xvector_PLDA_sp.StatObject_SB
          A StatServer in which stat1 are xvectors.
      ndx : speechbrain.utils.Xvector_PLDA_sp.Ndx
          An Ndx object defining the list of trials to perform.
      mu : double
          The mean vector of the PLDA gaussian.
      F : tensor
          The between-class co-variance matrix of the PLDA.
      Sigma: tensor
          The residual covariance matrix.
      p_known : float
          Probability of having a known speaker for open-set
          identification case (=1 for the verification task and =0 for the
          closed-set case).
      check_missing : bool
          If True, check that all models and segments exist.
      """
  
      enroll_ctr = copy.deepcopy(enroll)
      test_ctr = copy.deepcopy(test)
  
      # If models are not unique, compute the mean per model, display a warning
      if (
          not numpy.unique(enroll_ctr.modelset).shape
          == enroll_ctr.modelset.shape
      ):
          # logging.warning("Enrollment models are not unique, average i-vectors")
          enroll_ctr = enroll_ctr.mean_stat_per_model()
  
      # Remove missing models and test segments
      if check_missing:
          clean_ndx = _check_missing_model(enroll_ctr, test_ctr, ndx)
      else:
          clean_ndx = ndx
  
      # Center the i-vectors around the PLDA mean
      enroll_ctr.center_stat1(mu)
      test_ctr.center_stat1(mu)
  
      # If models are not unique, compute the mean per model, display a warning
      if (
          not numpy.unique(enroll_ctr.modelset).shape
          == enroll_ctr.modelset.shape
      ):
          # logging.warning("Enrollment models are not unique, average i-vectors")
          enroll_ctr = enroll_ctr.mean_stat_per_model()
  
      # Compute constant component of the PLDA distribution
      invSigma = linalg.inv(Sigma)
      I_spk = numpy.eye(F.shape[1], dtype="float")
  
      K = F.T.dot(invSigma * scaling_factor).dot(F)
      K1 = linalg.inv(K + I_spk)
      K2 = linalg.inv(2 * K + I_spk)
  
      # Compute the Gaussian distribution constant
      alpha1 = numpy.linalg.slogdet(K1)[1]
      alpha2 = numpy.linalg.slogdet(K2)[1]
      plda_cst = alpha2 / 2.0 - alpha1
  
      # Compute intermediate matrices
      Sigma_ac = numpy.dot(F, F.T)
      Sigma_tot = Sigma_ac + Sigma
      Sigma_tot_inv = linalg.inv(Sigma_tot)
  
      Tmp = linalg.inv(
          Sigma_tot - Sigma_ac.dot(Sigma_tot_inv).dot(Sigma_ac)
      )
      Phi = Sigma_tot_inv - Tmp
      Psi = Sigma_tot_inv.dot(Sigma_ac).dot(Tmp)
  
      # Compute the different parts of PLDA score
      model_part = 0.5 * numpy.einsum(
          "ij, ji->i", enroll_ctr.stat1.dot(Phi), enroll_ctr.stat1.T
      )
      seg_part = 0.5 * numpy.einsum(
          "ij, ji->i", test_ctr.stat1.dot(Phi), test_ctr.stat1.T
      )
  
      # Compute verification scores
      score = Scores()  # noqa F821
      score.modelset = clean_ndx.modelset
      score.segset = clean_ndx.segset
      score.scoremask = clean_ndx.trialmask
  
      score.scoremat = (
          model_part[:, numpy.newaxis] + seg_part + plda_cst
      )
      score.scoremat += enroll_ctr.stat1.dot(Psi).dot(test_ctr.stat1.T)
      score.scoremat *= scaling_factor
  
      # Case of open-set identification, we compute the log-likelihood
      # by taking into account the probability of having a known impostor
      # or an out-of set class
      if p_known != 0:
          N = score.scoremat.shape[0]
          open_set_scores = numpy.empty(score.scoremat.shape)
          tmp = numpy.exp(score.scoremat)
          for ii in range(N):
              # open-set term
              open_set_scores[ii, :] = score.scoremat[
                  ii, :
              ] - numpy.log(
                  p_known
                  * tmp[~(numpy.arange(N) == ii)].sum(axis=0)
                  / (N - 1)
                  + (1 - p_known)
              )
          score.scoremat = open_set_scores
  
      return score
  
imports: import numpy
  import copy
  import pickle
  from scipy import linalg
label_desc: Use image node_id 5 for calling a global function with example usage: fast_PLDA_scoring(enroll, test, ndx, mu, F, Sigma, test_uncertainty, Vtrans, p_known, scaling_factor, check_missing) and returns: score