code: def test_kernel_forward(kernel, X, Z, K_sum):
      K = kernel(X, Z)
      assert K.shape == (X.shape[0], (X if Z is None else Z).shape[0])
      if K_sum is not None:
          assert_equal(K.sum().item(), K_sum)
      assert_equal(kernel(X).diag(), kernel(X, diag=True))
      if not isinstance(
          kernel, WhiteNoise
      ):  # WhiteNoise avoids computing a delta function by assuming X != Z
          assert_equal(kernel(X), kernel(X, X))
      if Z is not None:
          assert_equal(kernel(X, Z), kernel(Z, X).t())
  
file_path: pyro/tests/contrib/gp/test_kernels.py
imports: from collections import namedtuple
  import pytest
  import torch
  from pyro.contrib.gp.kernels import RBF, Brownian, Constant, Coregionalize, Cosine, Exponent, Exponential, Linear, Matern32, Matern52, Periodic, Polynomial, Product, RationalQuadratic, Sum, VerticalScaling, Warping, WhiteNoise
  from tests.common import assert_equal
label_desc: Use image node_id 1 for calling a global function with example usage: test_kernel_forward(kernel, X, Z, K_sum) without return types