class_docstr: Computes a covariance matrix based on the Spectral Mixture Kernel
  between inputs :math:`\mathbf{x_1}` and :math:`\mathbf{x_2}`.
  
  It was proposed in `Gaussian Process Kernels for Pattern Discovery and Extrapolation`_.
  
  .. note::
      Unlike other kernels,
  
          * ard_num_dims **must equal** the number of dimensions of the data.
          * This kernel should not be combined with a :class:`gpytorch.kernels.ScaleKernel`.
  
  :param int num_mixtures: The number of components in the mixture.
  :param int ard_num_dims: Set this to match the dimensionality of the input.
      It should be `d` if x1 is a `... x n x d` matrix. (Default: `1`.)
  :param batch_shape: Set this if the data is batch of input data. It should
      be `b_1 x ... x b_j` if x1 is a `b_1 x ... x b_j x n x d` tensor. (Default: `torch.Size([])`.)
  :type batch_shape: torch.Size, optional
  :param active_dims: Set this if you want to compute the covariance of only
      a few input dimensions. The ints corresponds to the indices of the dimensions. (Default: `None`.)
  :type active_dims: float, optional
  :param eps: The minimum value that the lengthscale can take (prevents divide by zero errors). (Default: `1e-6`.)
  :type eps: float, optional
  
  :param mixture_scales_prior: A prior to set on the mixture_scales parameter
  :type mixture_scales_prior: ~gpytorch.priors.Prior, optional
  :param mixture_scales_constraint: A constraint to set on the mixture_scales parameter
  :type mixture_scales_constraint: ~gpytorch.constraints.Interval, optional
  :param mixture_means_prior: A prior to set on the mixture_means parameter
  :type mixture_means_prior: ~gpytorch.priors.Prior, optional
  :param mixture_means_constraint: A constraint to set on the mixture_means parameter
  :type mixture_means_constraint: ~gpytorch.constraints.Interval, optional
  :param mixture_weights_prior: A prior to set on the mixture_weights parameter
  :type mixture_weights_prior: ~gpytorch.priors.Prior, optional
  :param mixture_weights_constraint: A constraint to set on the mixture_weights parameter
  :type mixture_weights_constraint: ~gpytorch.constraints.Interval, optional
  
  :ivar torch.Tensor mixture_scales: The lengthscale parameter. Given
      `k` mixture components, and `... x n x d` data, this will be of size `... x k x 1 x d`.
  :ivar torch.Tensor mixture_means: The mixture mean parameters (`... x k x 1 x d`).
  :ivar torch.Tensor mixture_weights: The mixture weight parameters (`... x k`).
  
  Example:
  
      >>> # Non-batch
      >>> x = torch.randn(10, 5)
      >>> covar_module = gpytorch.kernels.SpectralMixtureKernel(num_mixtures=4, ard_num_dims=5)
      >>> covar = covar_module(x)  # Output: LazyVariable of size (10 x 10)
      >>>
      >>> # Batch
      >>> batch_x = torch.randn(2, 10, 5)
      >>> covar_module = gpytorch.kernels.SpectralMixtureKernel(num_mixtures=4, batch_size=2, ard_num_dims=5)
      >>> covar = covar_module(x)  # Output: LazyVariable of size (10 x 10)
  
  .. _Gaussian Process Kernels for Pattern Discovery and Extrapolation:
      https://arxiv.org/pdf/1302.4245.pdf
docstr: This is a helper method for creating a grid of the kernel's inputs.
  Use this helper rather than maually creating a meshgrid.
  
  The grid dimensions depend on the kernel's evaluation mode.
  
  :param torch.Tensor x1: ... x n x d
  :param torch.Tensor x2: ... x m x d (for diag mode, these must be the same inputs)
  :param diag: Should the Kernel compute the whole kernel, or just the diag? (Default: True.)
  :type diag: bool, optional
  :param last_dim_is_batch: If this is true, it treats the last dimension
      of the data as another batch dimension.  (Useful for additive
      structure over the dimensions). (Default: False.)
  :type last_dim_is_batch: bool, optional
  
  :rtype: torch.Tensor, torch.Tensor
  :return: Grid corresponding to x1 and x2. The shape depends on the kernel's mode:
      * `full_covar`: (`... x n x 1 x d` and `... x 1 x m x d`)
      * `full_covar` with `last_dim_is_batch=True`: (`... x k x n x 1 x 1` and `... x k x 1 x m x 1`)
      * `diag`: (`... x n x d` and `... x n x d`)
      * `diag` with `last_dim_is_batch=True`: (`... x k x n x 1` and `... x k x n x 1`)
docstr_tok: ["This","is","a","helper","method","for","creating","a","grid","of","the","kernel","'s","inputs",".","Use","this","helper","rather","than","maually","creating","a","meshgrid",".","The","grid","dimensions","depend","on","the","kernel","'s","evaluation","mode",".",":","param","torch.Tensor","x1",":","...","x","n","x","d",":","param","torch.Tensor","x2",":","...","x","m","x","d","(","for","diag","mode",",","these","must","be","the","same","inputs",")",":","param","diag",":","Should","the","Kernel","compute","the","whole","kernel",",","or","just","the","diag","?","(","Default",":","True",".",")",":","type","diag",":","bool",",","optional",":","param","last_dim_is_batch",":","If","this","is","true",",","it","treats","the","last","dimension","of","the","data","as","another","batch","dimension",".","(","Useful","for","additive","structure","over","the","dimensions",")",".","(","Default",":","False",".",")",":","type","last_dim_is_batch",":","bool",",","optional",":","rtype",":","torch.Tensor",",","torch.Tensor",":","return",":","Grid","corresponding","to","x1","and","x2",".","The","shape","depends","on","the","kernel","'s","mode",":","*","`","full_covar","`",":","(","`","...","x","n","x","1","x","d","`","and","`","...","x","1","x","m","x","d","`",")","*","`","full_covar","`","with","`","last_dim_is_batch=True","`",":","(","`","...","x","k","x","n","x","1","x","1","`","and","`","...","x","k","x","1","x","m","x","1","`",")","*","`","diag","`",":","(","`","...","x","n","x","d","`","and","`","...","x","n","x","d","`",")","*","`","diag","`","with","`","last_dim_is_batch=True","`",":","(","`","...","x","k","x","n","x","1","`","and","`","...","x","k","x","n","x","1","`",")"]
code: def _create_input_grid(
      self,
      x1: torch.Tensor,
      x2: torch.Tensor,
      diag: bool = False,
      last_dim_is_batch: bool = False,
      **params,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """
      This is a helper method for creating a grid of the kernel's inputs.
      Use this helper rather than maually creating a meshgrid.
  
      The grid dimensions depend on the kernel's evaluation mode.
  
      :param torch.Tensor x1: ... x n x d
      :param torch.Tensor x2: ... x m x d (for diag mode, these must be the same inputs)
      :param diag: Should the Kernel compute the whole kernel, or just the diag? (Default: True.)
      :type diag: bool, optional
      :param last_dim_is_batch: If this is true, it treats the last dimension
          of the data as another batch dimension.  (Useful for additive
          structure over the dimensions). (Default: False.)
      :type last_dim_is_batch: bool, optional
  
      :rtype: torch.Tensor, torch.Tensor
      :return: Grid corresponding to x1 and x2. The shape depends on the kernel's mode:
          * `full_covar`: (`... x n x 1 x d` and `... x 1 x m x d`)
          * `full_covar` with `last_dim_is_batch=True`: (`... x k x n x 1 x 1` and `... x k x 1 x m x 1`)
          * `diag`: (`... x n x d` and `... x n x d`)
          * `diag` with `last_dim_is_batch=True`: (`... x k x n x 1` and `... x k x n x 1`)
      """
      x1_, x2_ = x1, x2
      if last_dim_is_batch:
          x1_ = x1_.transpose(-1, -2).unsqueeze(-1)
          if torch.equal(x1, x2):
              x2_ = x1_
          else:
              x2_ = x2_.transpose(-1, -2).unsqueeze(-1)
  
      if diag:
          return x1_, x2_
      else:
          return x1_.unsqueeze(-2), x2_.unsqueeze(-3)
  
imports: import logging
  import math
  from typing import Optional, Tuple, Union
  import torch
  from ..constraints import Interval, Positive
  from ..priors import Prior
  from .kernel import Kernel
label_desc: Use image node_id 13 for calling the SpectralMixtureKernel obj's underlying member method code with example usage: obj._create_input_grid(x1, x2, diag, last_dim_is_batch) and returns: x1_,  x2_, x1_,  x2_