class_docstr: The SpectralMixture kernel.
  
  This kernel is derived from parameterizing the spectral density of a
  stationary kernel by a mixture of `m` diagonal multivariate normal
  distributions [1].
  
  This in turn parameterizes the following kernel:
  
    ```none
    k(x, y) = sum_j w[j] (prod_i
        exp(-2 * (pi * (x[i] - y[i]) * s[j][i])**2) *
        cos(2 * pi * (x[i] - y[i]) * m[j][i]))
    ```
  
  where:
    * `j` is the number of mixtures (as mentioned above).
    * `w[j]` are the mixture weights.
    * `m[j]` and `s[j]` parameterize a `MultivariateNormalDiag(m[j], s[j])`.
      In other words, they are the mean and diagonal scale for each mixture
      component.
  
  NOTE: This kernel can result in negative off-diagonal entries.
  
  #### References
  [1]: A. Wilson, R. P. Adams.
       Gaussian Process Kernels for Pattern Discovery and Extrapolation.
       https://arxiv.org/abs/1302.4245
class_docstr_tok: ["The","SpectralMixture","kernel",".","This","kernel","is","derived","from","parameterizing","the","spectral","density","of","a","stationary","kernel","by","a","mixture","of","`","m","`","diagonal","multivariate","normal","distributions","[","1","]",".","This","in","turn","parameterizes","the","following","kernel",":","``","`","none","k","(","x",",","y",")","=","sum_j","w","[","j","]","(","prod_i","exp","(","-2","*","(","pi","*","(","x","[","i","]","-","y","[","i","]",")","*","s","[","j","]","[","i","]",")","*","*","2",")","*","cos","(","2","*","pi","*","(","x","[","i","]","-","y","[","i","]",")","*","m","[","j","]","[","i","]",")",")","``","`","where",":","*","`","j","`","is","the","number","of","mixtures","(","as","mentioned","above",")",".","*","`","w","[","j","]","`","are","the","mixture","weights",".","*","`","m","[","j","]","`","and","`","s","[","j","]","`","parameterize","a","`","MultivariateNormalDiag","(","m","[","j","]",",","s","[","j","]",")","`",".","In","other","words",",","they","are","the","mean","and","diagonal","scale","for","each","mixture","component",".","NOTE",":","This","kernel","can","result","in","negative","off-diagonal","entries",".","#","#","#","#","References","[","1","]",":","A.","Wilson",",","R.","P.","Adams",".","Gaussian","Process","Kernels","for","Pattern","Discovery","and","Extrapolation",".","https",":","\/\/arxiv.org\/abs\/1302.4245"]
code: def _matrix(self, x1, x2):
      # Add an extra dimension to x1 and x2 so it broadcasts with scales.
      x1 = util.pad_shape_with_ones(
          x1, ndims=1, start=-(self.feature_ndims + 2)
      )
      x2 = util.pad_shape_with_ones(
          x2, ndims=1, start=-(self.feature_ndims + 2)
      )
      scales = util.pad_shape_with_ones(
          self.scales, ndims=1, start=-(self.feature_ndims + 1)
      )
      pairwise_square_distance = util.pairwise_square_distance_matrix(
          np.pi * x1 * scales, np.pi * x2 * scales, self.feature_ndims
      )
      x1 = util.pad_shape_with_ones(
          x1, ndims=1, start=-(self.feature_ndims + 1)
      )
      x2 = util.pad_shape_with_ones(
          x2, ndims=1, start=-(self.feature_ndims + 2)
      )
      # Expand `x1` and `x2` so that the broadcast against each other.
      return self._apply_with_distance(
          x1, x2, pairwise_square_distance, example_ndims=2
      )
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import assert_util
  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 tensor_util
  from tensorflow_probability.python.math import generic
  from tensorflow_probability.python.math.psd_kernels import positive_semidefinite_kernel
  from tensorflow_probability.python.math.psd_kernels.internal import util
label_desc: Use image node_id 8 for calling the SpectralMixture obj's underlying member method code with example usage: obj._matrix(x1, x2) and returns: self