class_docstr: Polynomial Kernel.
  
  Is based on the dot product covariance function and can be obtained
  from polynomial regression. This kernel, when parameterizing a
  Gaussian Process, results in random polynomial functions.
  A linear kernel can be created from this by setting the exponent to 1
  or None.
  
  ```none
  k(x, y) = bias_amplitude**2 + slope_amplitude**2 *
            ((x - shift) dot (y - shift))**exponent
  ```
  
  #### References
  
  [1]: Carl Edward Rasmussen and Christopher K. I. Williams. Gaussian
       Processes for Machine Learning. Section 4.4.2. 2006.
       http://www.gaussianprocess.org/gpml/chapters/RW4.pdf
  [2]: David Duvenaud. The Kernel Cookbook.
       https://www.cs.toronto.edu/~duvenaud/cookbook/
class_docstr_tok: ["Polynomial","Kernel",".","Is","based","on","the","dot","product","covariance","function","and","can","be","obtained","from","polynomial","regression",".","This","kernel",",","when","parameterizing","a","Gaussian","Process",",","results","in","random","polynomial","functions",".","A","linear","kernel","can","be","created","from","this","by","setting","the","exponent","to","1","or","None",".","``","`","none","k","(","x",",","y",")","=","bias_amplitude","*","*","2","+","slope_amplitude","*","*","2","*","(","(","x","-","shift",")","dot","(","y","-","shift",")",")","*","*","exponent","``","`","#","#","#","#","References","[","1","]",":","Carl","Edward","Rasmussen","and","Christopher","K.","I.","Williams",".","Gaussian","Processes","for","Machine","Learning",".","Section","4.4.2",".","2006.","http",":","\/\/www.gaussianprocess.org\/gpml\/chapters\/RW4.pdf","[","2","]",":","David","Duvenaud",".","The","Kernel","Cookbook",".","https",":","\/\/www.cs.toronto.edu\/~duvenaud\/cookbook\/"]
code: def _matrix(self, x1, x2):
      if self.feature_ndims > 1:
          x1 = tf.reshape(
              x1,
              ps.concat(
                  [ps.shape(x1)[: -self.feature_ndims], [-1]], axis=-1
              ),
          )
          x2 = tf.reshape(
              x2,
              ps.concat(
                  [ps.shape(x2)[: -self.feature_ndims], [-1]], axis=-1
              ),
          )
      if self.shift is not None:
          if self.feature_ndims > 0:
              shift = self.shift[..., tf.newaxis, tf.newaxis]
          else:
              shift = self.shift[..., tf.newaxis]
          x1 = x1 - shift
          x2 = x2 - shift
      if self.feature_ndims > 0:
          dot_prod = tf.linalg.matmul(x1, x2, transpose_b=True)
      else:
          dot_prod = tf.linalg.einsum("...i,...j->...ij", x1, x2)
  
      if self.exponent is not None:
          exponent = tf.convert_to_tensor(self.exponent)[
              ..., tf.newaxis, tf.newaxis
          ]
          dot_prod = dot_prod**exponent
  
      if self.slope_amplitude is not None:
          slope_amplitude = tf.convert_to_tensor(self.slope_amplitude)[
              ..., tf.newaxis, tf.newaxis
          ]
          dot_prod = dot_prod * slope_amplitude**2.0
  
      if self.bias_amplitude is not None:
          bias_amplitude = tf.convert_to_tensor(self.bias_amplitude)[
              ..., tf.newaxis, tf.newaxis
          ]
          dot_prod = dot_prod + bias_amplitude**2.0
  
      return dot_prod
  
imports: 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.psd_kernels import positive_semidefinite_kernel
  from tensorflow_probability.python.math.psd_kernels.internal import util
label_desc: Use image node_id 7 for calling the Polynomial obj's underlying member method code with example usage: obj._matrix(x1, x2) and returns: dot_prod