code: def _calculate_ref_metric(
      preds: torch.Tensor, target: torch.Tensor, threshold: float
  ):
      """Calculate reference metric for `CriticalSuccessIndex`."""
      preds, target = preds.numpy(), target.numpy()
      preds = preds >= threshold
      target = target >= threshold
      return jaccard_score(preds.ravel(), target.ravel())
  
file_path: torchmetrics/tests/unittests/image/test_csi.py
imports: from functools import partial
  import pytest
  import torch
  from sklearn.metrics import jaccard_score
  from torchmetrics.functional.regression.csi import critical_success_index
  from torchmetrics.regression.csi import CriticalSuccessIndex
  from unittests import BATCH_SIZE, NUM_BATCHES, _Input
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester
label_desc: Use image node_id 1 for calling a global function with example usage: _calculate_ref_metric(preds, target, threshold) and returns: jaccard_score