code: def pearson_corrcoef(
      predictions: np.ndarray,
      labels: np.ndarray,
      fweights: Optional[np.ndarray] = None,
  ):
      covariance_matrices = np.cov(
          predictions, labels, fweights=fweights
      )
      denominator = np.sqrt(
          covariance_matrices[0, 0] * covariance_matrices[1, 1]
      )
      if np.around(denominator, decimals=5) == 0:
          expected_pearson_correlation = 0
      else:
          expected_pearson_correlation = (
              covariance_matrices[0, 1] / denominator
          )
      return expected_pearson_correlation
  
file_path: allennlp/tests/training/metrics/pearson_correlation_test.py
imports: from typing import Optional
  import numpy
  import torch
  from torch.testing import assert_allclose
  from allennlp.common.testing import AllenNlpTestCase, multi_device
  from allennlp.training.metrics import PearsonCorrelation
label_desc: Use image node_id 1 for calling a global function with example usage: pearson_corrcoef(predictions, labels, fweights) and returns: expected_pearson_correlation