code: def test_pearsonr():
      pred1 = mx.np.array([[0.3, 0.7], [0, 1.0], [0.4, 0.6]])
      label1 = mx.np.array([[1, 0], [0, 1], [0, 1]])
      pearsonr_expected_np = np.corrcoef(
          pred1.asnumpy().ravel(), label1.asnumpy().ravel()
      )[0, 1]
      pearsonr_expected_scipy, _ = pearsonr(
          pred1.asnumpy().ravel(), label1.asnumpy().ravel()
      )
      micro_pr = mx.gluon.metric.create("pearsonr")
  
      assert np.isnan(micro_pr.get()[1])
  
      micro_pr.update([label1], [pred1])
  
      np.testing.assert_almost_equal(
          micro_pr.get()[1], pearsonr_expected_np
      )
      np.testing.assert_almost_equal(
          micro_pr.get()[1], pearsonr_expected_scipy
      )
  
      pred2 = mx.np.array([[1, 2], [3, 2], [4, 6]])
      label2 = mx.np.array([[1, 0], [0, 1], [0, 1]])
      # Note that pred12 = pred1 + pred2; label12 = label1 + label2
      pred12 = mx.np.array(
          [[0.3, 0.7], [0, 1.0], [0.4, 0.6], [1, 2], [3, 2], [4, 6]]
      )
      label12 = mx.np.array(
          [[1, 0], [0, 1], [0, 1], [1, 0], [0, 1], [0, 1]]
      )
  
      pearsonr_expected_np = np.corrcoef(
          pred12.asnumpy().ravel(), label12.asnumpy().ravel()
      )[0, 1]
      pearsonr_expected_scipy, _ = pearsonr(
          pred12.asnumpy().ravel(), label12.asnumpy().ravel()
      )
  
      micro_pr.update([label2], [pred2])
      np.testing.assert_almost_equal(
          micro_pr.get()[1], pearsonr_expected_np
      )
      np.testing.assert_almost_equal(
          micro_pr.get()[1], pearsonr_expected_scipy
      )
  
imports: import mxnet
  from mxnet.test_utils import use_np
  import numpy
  import scipy
  from scipy.stats import pearsonr
  import json
  import math
  from common import xfail_when_nonstandard_decimal_separator
  from copy import deepcopy
label_desc: Use image node_id 12 for calling a global function with example usage: test_pearsonr() without return types