code: def test_cohenskappa_weights():
      # some tests for equivalent results with different options
      np.random.seed(9743678)
      table = np.random.randint(0, 10, size=(5, 5)) + 5 * np.eye(5)
  
      # example aggregation, 2 groups of levels
      mat = np.array([[1, 1, 1, 0, 0], [0, 0, 0, 1, 1]])
      table_agg = np.dot(np.dot(mat, table), mat.T)
      res1 = cohens_kappa(table, weights=np.arange(5) > 2, wt="linear")
      res2 = cohens_kappa(table_agg, weights=np.arange(2), wt="linear")
      assert_almost_equal(res1.kappa, res2.kappa, decimal=14)
      assert_almost_equal(res1.var_kappa, res2.var_kappa, decimal=14)
  
      # equivalence toeplitz with linear for special cases
      res1 = cohens_kappa(table, weights=2 * np.arange(5), wt="linear")
      res2 = cohens_kappa(
          table, weights=2 * np.arange(5), wt="toeplitz"
      )
      res3 = cohens_kappa(table, weights=res1.weights[0], wt="toeplitz")
      # 2-Dim weights
      res4 = cohens_kappa(table, weights=res1.weights)
  
      assert_almost_equal(res1.kappa, res2.kappa, decimal=14)
      assert_almost_equal(res1.var_kappa, res2.var_kappa, decimal=14)
  
      assert_almost_equal(res1.kappa, res3.kappa, decimal=14)
      assert_almost_equal(res1.var_kappa, res3.var_kappa, decimal=14)
  
      assert_almost_equal(res1.kappa, res4.kappa, decimal=14)
      assert_almost_equal(res1.var_kappa, res4.var_kappa, decimal=14)
  
      # equivalence toeplitz with quadratic for special cases
      res1 = cohens_kappa(
          table, weights=5 * np.arange(5) ** 2, wt="toeplitz"
      )
      res2 = cohens_kappa(
          table, weights=5 * np.arange(5), wt="quadratic"
      )
      assert_almost_equal(res1.kappa, res2.kappa, decimal=14)
      assert_almost_equal(res1.var_kappa, res2.var_kappa, decimal=14)
  
imports: import numpy
  from numpy.testing import assert_almost_equal, assert_equal, assert_allclose
  from statsmodels.stats.inter_rater import fleiss_kappa, cohens_kappa, to_table, aggregate_raters
  from statsmodels.tools.testing import Holder
label_desc: Use image node_id 3 for calling a global function with example usage: test_cohenskappa_weights() without return types