class_docstr: Determinantal point process (DPP) distribution.
  
  The DPP disribution parameterized by the eigenvalues and eigenvectors of the
  L-ensemble matrix. The L-ensemble matrix indicates the degree of "repulsion"
  between pairs of items.
  
  #### Mathematical details
  
  A Determinantal Point Process is a distribution over subsets of `n` items,
  called the *ground set*. The DPP is parameterized by a positive definite
  matrix of shape `n x n`, the L-ensemble matrix. It assigns to any subset `S`
  of `{1, ..., n}` the probability:
  
  ```none
  Pr(S) = det(L_S) / det(I + L)
  ```
  
  where:
  
  * `L` is the L-ensemble matrix parameterized by `eigenvalues` and
    `eigenvectors`, i.e. `L = U D U^T` for `U = eigenvectors` and
    `D = eigenvalues`.
  * `L_S` is the principal submatrix of `L` indexed by items in `S`. In Numpy
    slicing notation, `L_S = L[S, :][:, S]`.
  * `det` is the matrix determinant.
  
  Marginal probabilities, i.e. the probability that a sample from the DPP
  contains the subset S, are obtained by way of the marginal kernel:
  
  ```none
  K = L / (I + L)
  ```
  
  where `/` is the matrix inverse.
  
  When sampling a random set `A` from the DPP, the marginal probability of `S`,
  given by `exp(dpp.marginal_log_prob(S))`, is:
  
  ```none
  Pr(A is a superset of S) = det(K_S)
  ```
  
  This is a marginal probability in the following sense. If we think of the
  DPP as a joint distribution over `n` binary indicator variables, each telling
  whether a given element is in a given subset `S`, then we can consider the
  marginal distribution obtained by "summing" out some of these binary
  indicators. The resulting marginal distribution happens also to be a DPP. What
  is referred to as the `marginal_log_prob` of `S` (under the original DPP) is
  just the `log_prob` of `S` under the marginal DPP, obtained by summing out the
  indicators of the *complement* of S. This tells us the (log) probability that
  a sample from the full DPP includes `S` as a subset.
  
  Written in terms of sets, with each `S'` a subset of the complement of `S`:
  
  ```none
  det(K_S) = sum_{S' s.t. S' intersect S is empty} [ Pr(S union S') ]
  ```
  
  where `Pr(S union S')` is the probability of sampling exactly `S union S'`
  from the DPP.
  
  For further detail, see Theorem 2.2 of [3].
  
  #### Repulsion
  
  Rewriting `L = B B^T` (which in particular can be done using `B = U sqrt(D)`,
  where `D` are the eigenvalues and `U` the eigenvectors), we have
  
  ```none
  Pr(S) = Vol^2(b_s1, b_s2, ..., b_sk)
  ```
  
  where `b_s1, ...` is the `s1`th column of `B`. Hence, the probability of
  sampling two points simultaneously decreases as a function of how colinear
  their corresponding eigenvectors are.
  
  #### Sampling
  
  Sampling is implemented following the algorithm introduced in [2] (see also
  [3], Algorithm 1), and proceeds in two phases.
  
  Given an orthonormalization `L = U D U^T`:
  
  * First, an elementary DPP (E-DPP) is built by sampling a subset of
    eigenvectors `S` from a Bernoulli distribution with probs equal to
    `D / (D + 1)`. This E-DPP has the same eigenvectors `U` as `L`, but its
    eigenvalues are `1` iff the corresponding Bernoulli trial was succesful,
    `0` otherwise.
  
  * Then, a number of points `k` equal to the number of selected eigenvalues is
    selected iteratively from the elementary DPP. After sampling a point `i`,
    the kernel is updated by projecting it onto the subspace of eigenvectors
    orthogonal to the `i`th basis vector.
  
  #### Examples
  
  Sample points on the unit square grid:
  
  ```python
  import itertools
  import tensorflow as tf
  import tensorflow_probability as tfp
  import matplotlib.pyplot as plt
  
  tfd = tfp.distributions
  tfpk = tfp.math.psd_kernels
  
  grid_size = 16
  # Generate grid_size**2 pts on the unit square.
  grid = np.arange(0, 1, 1./grid_size)
  points = np.array(list(itertools.product(grid, grid)))
  
  # Create the kernel L that parameterizes the DPP.
  kernel_amplitude = 2.
  kernel_lengthscale = 2. / grid_size
  kernel = tfpk.ExponentiatedQuadratic(kernel_amplitude, kernel_lengthscale)
  kernel_matrix = kernel.matrix(points, points)
  
  eigenvalues, eigenvectors = tf.linalg.eigh(kernel_matrix)
  dpp = tfd.DeterminantalPointProcess(eigenvalues, eigenvectors)
  
  # The inner-most dimension of the result of `dpp.sample` is a multi-hot
  # encoding of a subset of {1, ..., ground_set_size}.
  
  plt.figure(figsize=(6, 6))
  for i, samp in enumerate(dpp.sample(4, seed=(1, 2))):  # 4 x grid_size**2
    plt.subplot(221 + i)
    plt.scatter(*points[np.where(samp)].T)
    plt.xticks([])
    plt.yticks([])
  plt.tight_layout()
  plt.show()
  
  # Like any TFP distribution, the DPP supports batching and shaped samples.
  
  kernel_amplitude = [2., 3, 4]  # Build a batch of 3 PSD kernels.
  kernel_lengthscale = 2. / grid_size
  kernel = tfpk.ExponentiatedQuadratic(kernel_amplitude, kernel_lengthscale)
  kernel_matrix = kernel.matrix(points, points)  # 3 x 256 x 256
  
  eigenvalues, eigenvectors = tf.linalg.eigh(kernel_matrix)
  dpp = tfd.DeterminantalPointProcess(eigenvalues, eigenvectors)
  print(dpp)  # batch shape: [3], event shape: [256]
  samps = dpp.sample(2, seed=(10, 20))
  print(samps.shape)  # shape: [2, 3, 256]
  print(dpp.log_prob(samps))  # tensor with shape [2, 3]
  ```
  
  #### References
  
  [1]: Odile Macchi. The coincidence approach to stochastic point processes.
       _Advances in Applied Probability_, 1975.
  
  [2]: J. Ben Hough, Manjunath Krishnapur, Yuval Peres, Balint Virag.
       Determinantal point processes and independence. _Probability Surveys_,
       2006. https://arxiv.org/abs/math/0503110
  
  [3]: Alex Kulesza, Ben Taskar. Determinantal point processes for machine
       learning. _Foundations and Trends in Machine Learning_, 2012.
       https://arxiv.org/abs/1207.6083
class_docstr_tok: ["Determinantal","point","process","(","DPP",")","distribution",".","The","DPP","disribution","parameterized","by","the","eigenvalues","and","eigenvectors","of","the","L-ensemble","matrix",".","The","L-ensemble","matrix","indicates","the","degree","of","``","repulsion","''","between","pairs","of","items",".","#","#","#","#","Mathematical","details","A","Determinantal","Point","Process","is","a","distribution","over","subsets","of","`","n","`","items",",","called","the","*","ground","set","*",".","The","DPP","is","parameterized","by","a","positive","definite","matrix","of","shape","`","n","x","n","`",",","the","L-ensemble","matrix",".","It","assigns","to","any","subset","`","S","`","of","`","{","1",",","...",",","n","}","`","the","probability",":","``","`","none","Pr","(","S",")","=","det","(","L_S",")","\/","det","(","I","+","L",")","``","`","where",":","*","`","L","`","is","the","L-ensemble","matrix","parameterized","by","`","eigenvalues","`","and","`","eigenvectors","`",",","i.e",".","`","L","=","U","D","U^T","`","for","`","U","=","eigenvectors","`","and","`","D","=","eigenvalues","`",".","*","`","L_S","`","is","the","principal","submatrix","of","`","L","`","indexed","by","items","in","`","S","`",".","In","Numpy","slicing","notation",",","`","L_S","=","L","[","S",",",":","]","[",":",",","S","]","`",".","*","`","det","`","is","the","matrix","determinant",".","Marginal","probabilities",",","i.e",".","the","probability","that","a","sample","from","the","DPP","contains","the","subset","S",",","are","obtained","by","way","of","the","marginal","kernel",":","``","`","none","K","=","L","\/","(","I","+","L",")","``","`","where","`","\/","`","is","the","matrix","inverse",".","When","sampling","a","random","set","`","A","`","from","the","DPP",",","the","marginal","probability","of","`","S","`",",","given","by","`","exp","(","dpp.marginal_log_prob","(","S",")",")","`",",","is",":","``","`","none","Pr","(","A","is","a","superset","of","S",")","=","det","(","K_S",")","``","`","This","is","a","marginal","probability","in","the","following","sense",".","If","we","think","of","the","DPP","as","a","joint","distribution","over","`","n","`","binary","indicator","variables",",","each","telling","whether","a","given","element","is","in","a","given","subset","`","S","`",",","then","we","can","consider","the","marginal","distribution","obtained","by","``","summing","''","out","some","of","these","binary","indicators",".","The","resulting","marginal","distribution","happens","also","to","be","a","DPP",".","What","is","referred","to","as","the","`","marginal_log_prob","`","of","`","S","`","(","under","the","original","DPP",")","is","just","the","`","log_prob","`","of","`","S","`","under","the","marginal","DPP",",","obtained","by","summing","out","the","indicators","of","the","*","complement","*","of","S.","This","tells","us","the","(","log",")","probability","that","a","sample","from","the","full","DPP","includes","`","S","`","as","a","subset",".","Written","in","terms","of","sets",",","with","each","`","S","'","`","a","subset","of","the","complement","of","`","S","`",":","``","`","none","det","(","K_S",")","=","sum_","{","S","'","s.t",".","S","'","intersect","S","is","empty","}","[","Pr","(","S","union","S","'",")","]","``","`","where","`","Pr","(","S","union","S","'",")","`","is","the","probability","of","sampling","exactly","`","S","union","S","'","`","from","the","DPP",".","For","further","detail",",","see","Theorem","2.2","of","[","3","]",".","#","#","#","#","Repulsion","Rewriting","`","L","=","B","B^T","`","(","which","in","particular","can","be","done","using","`","B","=","U","sqrt","(","D",")","`",",","where","`","D","`","are","the","eigenvalues","and","`","U","`","the","eigenvectors",")",",","we","have","``","`","none","Pr","(","S",")","=","Vol^2","(","b_s1",",","b_s2",",","...",",","b_sk",")","``","`","where","`","b_s1",",","...","`","is","the","`","s1","`","th","column","of","`","B","`",".","Hence",",","the","probability","of","sampling","two","points","simultaneously","decreases","as","a","function","of","how","colinear","their","corresponding","eigenvectors","are",".","#","#","#","#","Sampling","Sampling","is","implemented","following","the","algorithm","introduced","in","[","2","]","(","see","also","[","3","]",",","Algorithm","1",")",",","and","proceeds","in","two","phases",".","Given","an","orthonormalization","`","L","=","U","D","U^T","`",":","*","First",",","an","elementary","DPP","(","E-DPP",")","is","built","by","sampling","a","subset","of","eigenvectors","`","S","`","from","a","Bernoulli","distribution","with","probs","equal","to","`","D","\/","(","D","+","1",")","`",".","This","E-DPP","has","the","same","eigenvectors","`","U","`","as","`","L","`",",","but","its","eigenvalues","are","`","1","`","iff","the","corresponding","Bernoulli","trial","was","succesful",",","`","0","`","otherwise",".","*","Then",",","a","number","of","points","`","k","`","equal","to","the","number","of","selected","eigenvalues","is","selected","iteratively","from","the","elementary","DPP",".","After","sampling","a","point","`","i","`",",","the","kernel","is","updated","by","projecting","it","onto","the","subspace","of","eigenvectors","orthogonal","to","the","`","i","`","th","basis","vector",".","#","#","#","#","Examples","Sample","points","on","the","unit","square","grid",":","``","`","python","import","itertools","import","tensorflow","as","tf","import","tensorflow_probability","as","tfp","import","matplotlib.pyplot","as","plt","tfd","=","tfp.distributions","tfpk","=","tfp.math.psd_kernels","grid_size","=","16","#","Generate","grid_size","*","*","2","pts","on","the","unit","square",".","grid","=","np.arange","(","0",",","1",",","1.\/grid_size",")","points","=","np.array","(","list","(","itertools.product","(","grid",",","grid",")",")",")","#","Create","the","kernel","L","that","parameterizes","the","DPP",".","kernel_amplitude","=","2.","kernel_lengthscale","=","2",".","\/","grid_size","kernel","=","tfpk.ExponentiatedQuadratic","(","kernel_amplitude",",","kernel_lengthscale",")","kernel_matrix","=","kernel.matrix","(","points",",","points",")","eigenvalues",",","eigenvectors","=","tf.linalg.eigh","(","kernel_matrix",")","dpp","=","tfd.DeterminantalPointProcess","(","eigenvalues",",","eigenvectors",")","#","The","inner-most","dimension","of","the","result","of","`","dpp.sample","`","is","a","multi-hot","#","encoding","of","a","subset","of","{","1",",","...",",","ground_set_size","}",".","plt.figure","(","figsize=","(","6",",","6",")",")","for","i",",","samp","in","enumerate","(","dpp.sample","(","4",",","seed=","(","1",",","2",")",")",")",":","#","4","x","grid_size","*","*","2","plt.subplot","(","221","+","i",")","plt.scatter","(","*","points","[","np.where","(","samp",")","]",".T",")","plt.xticks","(","[","]",")","plt.yticks","(","[","]",")","plt.tight_layout","(",")","plt.show","(",")","#","Like","any","TFP","distribution",",","the","DPP","supports","batching","and","shaped","samples",".","kernel_amplitude","=","[","2.",",","3",",","4","]","#","Build","a","batch","of","3","PSD","kernels",".","kernel_lengthscale","=","2",".","\/","grid_size","kernel","=","tfpk.ExponentiatedQuadratic","(","kernel_amplitude",",","kernel_lengthscale",")","kernel_matrix","=","kernel.matrix","(","points",",","points",")","#","3","x","256","x","256","eigenvalues",",","eigenvectors","=","tf.linalg.eigh","(","kernel_matrix",")","dpp","=","tfd.DeterminantalPointProcess","(","eigenvalues",",","eigenvectors",")","print","(","dpp",")","#","batch","shape",":","[","3","]",",","event","shape",":","[","256","]","samps","=","dpp.sample","(","2",",","seed=","(","10",",","20",")",")","print","(","samps.shape",")","#","shape",":","[","2",",","3",",","256","]","print","(","dpp.log_prob","(","samps",")",")","#","tensor","with","shape","[","2",",","3","]","``","`","#","#","#","#","References","[","1","]",":","Odile","Macchi",".","The","coincidence","approach","to","stochastic","point","processes",".","_Advances","in","Applied","Probability_",",","1975",".","[","2","]",":","J.","Ben","Hough",",","Manjunath","Krishnapur",",","Yuval","Peres",",","Balint","Virag",".","Determinantal","point","processes","and","independence",".","_Probability","Surveys_",",","2006.","https",":","\/\/arxiv.org\/abs\/math\/0503110","[","3","]",":","Alex","Kulesza",",","Ben","Taskar",".","Determinantal","point","processes","for","machine","learning",".","_Foundations","and","Trends","in","Machine","Learning_",",","2012.","https",":","\/\/arxiv.org\/abs\/1207.6083"]
code: def _parameter_control_dependencies(self, is_init):
      if not self.validate_args:
          return []
      checks = []
      if is_init != tensor_util.is_ref(self.eigenvectors):
          eigvecs = tf.convert_to_tensor(self.eigenvectors)
          checks += [
              tf.debugging.assert_near(
                  tf.eye(ps.shape(eigvecs)[-1], dtype=eigvecs.dtype),
                  tf.matmul(eigvecs, eigvecs, adjoint_b=True),
                  message="`eigenvectors` must be orthonormal.",
              ),
          ]
      if is_init != tensor_util.is_ref(self.eigenvalues):
          checks += [
              tf.debugging.assert_positive(
                  self.eigenvalues,
                  message="`eigenvalues` must be positive.",
              ),
          ]
  
      return checks
  
imports: import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import bernoulli
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.math.gram_schmidt import gram_schmidt
  from tensorflow.python.ops import control_flow_util
label_desc: Use image node_id 14 for calling the DeterminantalPointProcess obj's underlying member method code with example usage: obj._parameter_control_dependencies(is_init) and returns: checks, list