code: def test_training_loss_closure_with_minibatch() -> None:
      N = 13
      B = 5
      num_batches = int(np.ceil(N / B))
  
      data = (np.random.randn(N, 2), np.random.randn(N, 1))
      dataset = tf.data.Dataset.from_tensor_slices(data)
  
      model = DummyModel()
  
      training_loss_full_data = model.training_loss_closure(
          data, compile=True
      )
      loss_full = training_loss_full_data()
  
      it = iter(dataset.batch(B))
      training_loss_minibatch = model.training_loss_closure(
          it, compile=True
      )
      batch_losses = [
          training_loss_minibatch() for _ in range(num_batches)
      ]
  
      np.testing.assert_allclose(loss_full, np.sum(batch_losses))
  
file_path: GPflow/tests/gpflow/models/test_training_mixins.py
imports: import numpy
  import tensorflow
  import gpflow
  from gpflow.base import RegressionData
label_desc: Use image node_id 1 for calling a global function with example usage: test_training_loss_closure_with_minibatch() without return types