code: def test_binary_input(n_times, weights, test_data_binary):
      y_pred, y, batch_size = test_data_binary
      ck = CohenKappa(weights)
      ck.reset()
      if batch_size > 1:
          n_iters = y.shape[0] // batch_size + 1
          for i in range(n_iters):
              idx = i * batch_size
              ck.update(
                  (
                      y_pred[idx : idx + batch_size],
                      y[idx : idx + batch_size],
                  )
              )
      else:
          ck.update((y_pred, y))
  
      np_y = y.numpy()
      np_y_pred = y_pred.numpy()
  
      res = ck.compute()
      assert isinstance(res, float)
      assert cohen_kappa_score(
          np_y, np_y_pred, weights=weights
      ) == pytest.approx(res)
  
imports: import os
  from unittest.mock import patch
  import pytest
  import sklearn
  import torch
  from sklearn.metrics import cohen_kappa_score
  import ignite.distributed
  from ignite.contrib.metrics import CohenKappa
  from ignite.engine import Engine
  from ignite.exceptions import NotComputableError
label_desc: Use image node_id 8 for calling a global function with example usage: test_binary_input(n_times, weights, test_data_binary) without return types