code: def test_integration_binary_input(
      n_times, weights, test_data_integration_binary
  ):
      y_pred, y, batch_size = test_data_integration_binary
  
      def update_fn(engine, batch):
          idx = (engine.state.iteration - 1) * batch_size
          y_true_batch = np_y[idx : idx + batch_size]
          y_pred_batch = np_y_pred[idx : idx + batch_size]
          return torch.from_numpy(y_pred_batch), torch.from_numpy(
              y_true_batch
          )
  
      engine = Engine(update_fn)
  
      ck_metric = CohenKappa(weights=weights)
      ck_metric.attach(engine, "ck")
  
      np_y = y.numpy()
      np_y_pred = y_pred.numpy()
  
      np_ck = cohen_kappa_score(np_y, np_y_pred, weights=weights)
  
      data = list(range(y_pred.shape[0] // batch_size))
      ck = engine.run(data, max_epochs=1).metrics["ck"]
  
      assert isinstance(ck, float)
      assert np_ck == pytest.approx(ck)
  
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 11 for calling a global function with example usage: test_integration_binary_input(n_times, weights, test_data_integration_binary) and returns: torch,  torch