docstr: Compute the p-value resulting from a permutation test using the least-squares density
  difference as a distance measure between the reference data and the data to be tested.
  
  Parameters
  ----------
  x
      Batch of instances.
  
  Returns
  -------
  p-value obtained from the permutation test, the LSDD between the reference and test set,         and the LSDD threshold above which drift is flagged.
docstr_tok: ["Compute","the","p-value","resulting","from","a","permutation","test","using","the","least-squares","density","difference","as","a","distance","measure","between","the","reference","data","and","the","data","to","be","tested",".","Parameters","--","--","--","--","--","x","Batch","of","instances",".","Returns","--","--","--","-","p-value","obtained","from","the","permutation","test",",","the","LSDD","between","the","reference","and","test","set",",","and","the","LSDD","threshold","above","which","drift","is","flagged","."]
code: def score(
      self, x: Union[np.ndarray, list]
  ) -> Tuple[float, float, float]:
      """
          Compute the p-value resulting from a permutation test using the least-squares density
          difference as a distance measure between the reference data and the data to be tested.
  
          Parameters
          ----------
          x
              Batch of instances.
  
          Returns
          -------
          p-value obtained from the permutation test, the LSDD between the reference and test set, \
          and the LSDD threshold above which drift is flagged.
          """
      x_ref, x = self.preprocess(x)
  
      if (
          self.preprocess_fn is not None
          and not self.preprocess_at_init
          and not self.x_ref_preprocessed
      ):
          self._configure_normalization(x_ref)
          x_ref = self._normalize(x_ref)
          self._initialize_kernel(x_ref)
          self._configure_kernel_centers(x_ref)
          self.H = GaussianRBF(np.sqrt(2.0) * self.kernel.sigma)(
              self.kernel_centers, self.kernel_centers
          )
  
      x = self._normalize(x)
  
      k_yc = self.kernel(x, self.kernel_centers)
      k_all_c = tf.concat([self.k_xc, k_yc], axis=0)
  
      n_x = x_ref.shape[0] - self.n_kernel_centers
      n_all = k_all_c.shape[0]
      perms = [
          tf.random.shuffle(tf.range(n_all))
          for _ in range(self.n_permutations)
      ]
      x_perms = [perm[:n_x] for perm in perms]
      y_perms = [perm[n_x:] for perm in perms]
  
      lsdd_permuted, _, lsdd = permed_lsdds(  # type: ignore
          k_all_c,
          x_perms,
          y_perms,
          self.H,
          lam_rd_max=self.lambda_rd_max,
          return_unpermed=True,
      )
      p_val = tf.reduce_mean(tf.cast(lsdd <= lsdd_permuted, float))
  
      idx_threshold = int(self.p_val * len(lsdd_permuted))
      distance_threshold = np.sort(lsdd_permuted)[::-1][idx_threshold]
      return float(p_val), float(lsdd), float(distance_threshold)
  
file_path: alibi-detect/alibi_detect/cd/tensorflow/lsdd.py
imports: import numpy
  import tensorflow
  from typing import Callable, Dict, Optional, Tuple, Union
  from alibi_detect.cd.base import BaseLSDDDrift
  from alibi_detect.utils.tensorflow.kernels import GaussianRBF
  from alibi_detect.utils.tensorflow.distance import permed_lsdds
  from alibi_detect.utils.warnings import deprecated_alias
  from alibi_detect.utils.frameworks import Framework
label_desc: Use image node_id 5 for calling the LSDDDriftTF obj's underlying member method code with example usage: obj.score(x) and returns: float,  float,  float