code: def test_sumkl_equals_batchkl(shared_k: bool, diag: bool) -> None:
      """
      gauss_kl implicitely performs a sum of KL divergences
      This test checks that doing the sum outside of the function is equivalent
      For q(X)=prod q(x_l) and p(X)=prod p(x_l), check that sum KL(q(x_l)||p(x_l)) = KL(q(X)||p(X))
      Here, q(X) has covariance [L, M, M]
      p(X) has covariance [L, M, M] ( or [M, M] )
      Here, q(x_i) has covariance [1, M, M]
      p(x_i) has covariance [M, M]
      """
      s = Datum.sqrt_diag if diag else Datum.sqrt
      kl_batch = gauss_kl(
          Datum.mu, s, Datum.K if shared_k else Datum.K_batch
      )
      kl_sum = []
      for n in range(Datum.N):
          q_mu_n = Datum.mu[:, n][:, None]  # [M, 1]
          q_sqrt_n = (
              Datum.sqrt_diag[:, n][:, None]
              if diag
              else Datum.sqrt[n, :, :][None, :, :]
          )  # [1, M, M] or [M, 1]
          K_n = (
              Datum.K
              if shared_k
              else Datum.K_batch[n, :, :][None, :, :]
          )  # [1, M, M] or [M, M]
          kl_n = gauss_kl(q_mu_n, q_sqrt_n, K=K_n)
          kl_sum.append(kl_n)
  
      kl_sum = tf.reduce_sum(kl_sum)
      assert_almost_equal(kl_sum, kl_batch)
  
imports: from unittest.mock import patch
  import numpy
  import pytest
  import tensorflow
  from check_shapes import ShapeChecker, check_shapes
  from numpy.testing import assert_allclose, assert_almost_equal
  import gpflow
  from gpflow import Parameter, default_float, default_jitter
  from gpflow.base import AnyNDArray, TensorType
  from gpflow.inducing_variables import InducingPoints
  from gpflow.kernels import Kernel
  from gpflow.kullback_leiblers import gauss_kl, prior_kl
  from gpflow.utilities.bijectors import triangular
label_desc: Use image node_id 10 for calling a global function with example usage: test_sumkl_equals_batchkl(shared_k, diag) without return types