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 _apply(self, x1, x2, example_ndims=0):
      if self.shift is None:
          dot_prod = util.sum_rightmost_ndims_preserving_shape(
              x1 * x2, ndims=self.feature_ndims
          )
      else:
          shift = tf.convert_to_tensor(self.shift)
          shift = util.pad_shape_with_ones(
              shift, example_ndims + self.feature_ndims
          )
          dot_prod = util.sum_rightmost_ndims_preserving_shape(
              (x1 - shift) * (x2 - shift), ndims=self.feature_ndims
          )
  
      if self.exponent is not None:
          exponent = tf.convert_to_tensor(self.exponent)
          exponent = util.pad_shape_with_ones(exponent, example_ndims)
          dot_prod = dot_prod**exponent
  
      slope_amplitude = self.slope_amplitude
      if slope_amplitude is not None:
          slope_amplitude = tf.convert_to_tensor(slope_amplitude)
          slope_amplitude = util.pad_shape_with_ones(
              slope_amplitude, example_ndims
          )
          dot_prod = dot_prod * slope_amplitude**2.0
  
      bias_amplitude = self.bias_amplitude
      if bias_amplitude is not None:
          bias_amplitude = tf.convert_to_tensor(bias_amplitude)
          bias_amplitude = util.pad_shape_with_ones(
              bias_amplitude, example_ndims
          )
          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 8 for calling the Polynomial obj's underlying member method code with example usage: obj._apply(x1, x2, example_ndims) and returns: dot_prod