code: def test_per_batch(func):
      gt = np.stack([GT0, GT1], axis=0)
      pr = np.stack([PR1, PR2], axis=0)
  
      gt = _add_4d(gt)
      pr = _add_4d(pr)
  
      # calculate score per batch
      score_1 = keras.backend.eval(
          func(per_image=False, smooth=10e-12)(gt, pr)
      )
  
      gt1 = np.concatenate([GT0, GT1], axis=0)
      pr1 = np.concatenate([PR1, PR2], axis=0)
      score_2 = keras.backend.eval(
          func(per_image=True, smooth=10e-12)(_to_4d(gt1), _to_4d(pr1))
      )
  
      assert np.allclose(score_1, score_2)
  
file_path: segmentation_models/tests/test_metrics.py
imports: import pytest
  import numpy
  import segmentation_models
  from segmentation_models.metrics import IOUScore, FScore
  from segmentation_models.losses import JaccardLoss, DiceLoss
label_desc: Use image node_id 10 for calling a global function with example usage: test_per_batch(func) without return types