code: def test_binary_input(average):
      re = Recall(average=average)
      assert re._updated is False
  
      def _test(y_pred, y, batch_size):
          re.reset()
          assert re._updated is False
  
          if batch_size > 1:
              n_iters = y.shape[0] // batch_size + 1
              for i in range(n_iters):
                  idx = i * batch_size
                  re.update(
                      (
                          y_pred[idx : idx + batch_size],
                          y[idx : idx + batch_size],
                      )
                  )
          else:
              re.update((y_pred, y))
  
          np_y = y.numpy().ravel()
          np_y_pred = y_pred.numpy().ravel()
  
          assert re._type == "binary"
          assert re._updated is True
          assert isinstance(
              re.compute(), torch.Tensor if not average else float
          )
          re_compute = (
              re.compute().numpy() if not average else re.compute()
          )
          sk_average_parameter = ignite_average_to_scikit_average(
              average, "binary"
          )
          assert recall_score(
              np_y,
              np_y_pred,
              average=sk_average_parameter,
              labels=[0, 1],
          ) == pytest.approx(re_compute)
  
      def get_test_cases():
          test_cases = [
              # Binary accuracy on input of shape (N, 1) or (N, )
              (
                  torch.randint(0, 2, size=(10,)),
                  torch.randint(0, 2, size=(10,)),
                  1,
              ),
              (
                  torch.randint(0, 2, size=(10, 1)),
                  torch.randint(0, 2, size=(10, 1)),
                  1,
              ),
              # updated batches
              (
                  torch.randint(0, 2, size=(50,)),
                  torch.randint(0, 2, size=(50,)),
                  16,
              ),
              (
                  torch.randint(0, 2, size=(50, 1)),
                  torch.randint(0, 2, size=(50, 1)),
                  16,
              ),
              # Binary accuracy on input of shape (N, L)
              (
                  torch.randint(0, 2, size=(10, 5)),
                  torch.randint(0, 2, size=(10, 5)),
                  1,
              ),
              (
                  torch.randint(0, 2, size=(10, 1, 5)),
                  torch.randint(0, 2, size=(10, 1, 5)),
                  1,
              ),
              # updated batches
              (
                  torch.randint(0, 2, size=(50, 5)),
                  torch.randint(0, 2, size=(50, 5)),
                  16,
              ),
              (
                  torch.randint(0, 2, size=(50, 1, 5)),
                  torch.randint(0, 2, size=(50, 1, 5)),
                  16,
              ),
              # Binary accuracy on input of shape (N, H, W)
              (
                  torch.randint(0, 2, size=(10, 12, 10)),
                  torch.randint(0, 2, size=(10, 12, 10)),
                  1,
              ),
              (
                  torch.randint(0, 2, size=(10, 1, 12, 10)),
                  torch.randint(0, 2, size=(10, 1, 12, 10)),
                  1,
              ),
              # updated batches
              (
                  torch.randint(0, 2, size=(50, 12, 10)),
                  torch.randint(0, 2, size=(50, 12, 10)),
                  16,
              ),
              (
                  torch.randint(0, 2, size=(50, 1, 12, 10)),
                  torch.randint(0, 2, size=(50, 1, 12, 10)),
                  16,
              ),
              # Corner case with all zeros predictions
              (
                  torch.zeros(size=(10,), dtype=torch.long),
                  torch.randint(0, 2, size=(10,)),
                  1,
              ),
              (
                  torch.zeros(size=(10, 1), dtype=torch.long),
                  torch.randint(0, 2, size=(10, 1)),
                  1,
              ),
          ]
  
          return test_cases
  
      for _ in range(5):
          # check multiple random inputs as random exact occurencies are rare
          test_cases = get_test_cases()
          for y_pred, y, batch_size in test_cases:
              _test(y_pred, y, batch_size)
  
imports: import os
  import warnings
  import pytest
  import torch
  from sklearn.exceptions import UndefinedMetricWarning
  from sklearn.metrics import recall_score
  import ignite.distributed
  from ignite.exceptions import NotComputableError
  from ignite.metrics import Recall
label_desc: Use image node_id 5 for calling a global function with example usage: test_binary_input(average) and returns: test_cases