class_docstr: Computes a covariance matrix based on the Periodic kernel
  between inputs :math:`\mathbf{x_1}` and :math:`\mathbf{x_2}`:
  :math:`k_{\text{Per}}(\mathbf{x_1}, \mathbf{x_2}) = \theta_0 \exp \left
  (\frac{-2\sin^2(\theta_2 \pi \|\mathbf{x_1} - \mathbf{x_2}\|)}
  {\theta_1^2} \right)`,
  where :math:`\theta_0` is the amplitude parameter,
  :math:`\theta_1` is the length scale parameter and
  :math:`\theta_2` is the frequency parameter.
class_docstr_tok: ["Computes","a","covariance","matrix","based","on","the","Periodic","kernel","between","inputs",":","math",":","`","\\mathbf","{","x_1","}","`","and",":","math",":","`","\\mathbf","{","x_2","}","`",":",":","math",":","`","k_","{","\\text","{","Per","}","}","(","\\mathbf","{","x_1","}",",","\\mathbf","{","x_2","}",")","=","\\theta_0","\\exp","\\left","(","\\frac","{","-2\\sin^2","(","\\theta_2","\\pi","\\|\\mathbf","{","x_1","}","-","\\mathbf","{","x_2","}","\\|",")","}","{","\\theta_1^2","}","\\right",")","`",",","where",":","math",":","`","\\theta_0","`","is","the","amplitude","parameter",",",":","math",":","`","\\theta_1","`","is","the","length","scale","parameter","and",":","math",":","`","\\theta_2","`","is","the","frequency","parameter","."]
docstr: Parameters
  --------------------
  x1 : Tensor
      Feature data of shape (batch_size, history_length, num_features).
  x2 : Tensor
      Feature data of shape (batch_size, history_length, num_features).
  
  Returns
  --------------------
  Tensor
      Periodic kernel matrix of shape (batch_size, history_length,
      history_length).
docstr_tok: ["Parameters","--","--","--","--","--","--","--","--","--","--","x1",":","Tensor","Feature","data","of","shape","(","batch_size",",","history_length",",","num_features",")",".","x2",":","Tensor","Feature","data","of","shape","(","batch_size",",","history_length",",","num_features",")",".","Returns","--","--","--","--","--","--","--","--","--","--","Tensor","Periodic","kernel","matrix","of","shape","(","batch_size",",","history_length",",","history_length",")","."]
code: def kernel_matrix(self, x1: Tensor, x2: Tensor) -> Tensor:
      """
      Parameters
      --------------------
      x1 : Tensor
          Feature data of shape (batch_size, history_length, num_features).
      x2 : Tensor
          Feature data of shape (batch_size, history_length, num_features).
  
      Returns
      --------------------
      Tensor
          Periodic kernel matrix of shape (batch_size, history_length,
          history_length).
      """
      self._compute_square_dist(self.F, x1, x2)
  
      return self.F.broadcast_mul(
          self.amplitude,
          self.F.exp(
              self.F.broadcast_div(
                  -2
                  * self.F.sin(
                      self.F.broadcast_mul(
                          self.frequency,
                          math.pi
                          * self.F.sqrt(self.F.abs(self.square_dist)),
                      )
                  )
                  ** 2,
                  self.length_scale**2,
              )
          ),
      )
  
file_path: gluonts/src/gluonts/mx/kernels/_periodic_kernel.py
imports: import math
  from typing import Dict, Tuple
  from gluonts.mx import Tensor
  from gluonts.mx.distribution.distribution import getF, softplus
  from .None import Kernel, KernelOutputDict
label_desc: Use image node_id 2 for calling the PeriodicKernel obj's underlying member method code with example usage: obj.kernel_matrix(x1, x2) and returns: self