code: def test_spin2_matrix_elements(n_spin_orbs, matrix_ref):
      r"""Test the calculation of the matrix elements of the two-particle spin operator
      :math:`\hat{s}_1 \cdot \hat{s}_2` implemented by the function `'_spin2_matrix_elements'`
      """
      # pylint: disable=protected-access
  
      sz = np.where(np.arange(n_spin_orbs) % 2 == 0, 0.5, -0.5)
  
      s2_me_result = qchem.spin._spin2_matrix_elements(sz)
  
      assert np.allclose(s2_me_result, matrix_ref)
  
file_path: pennylane/tests/qchem/test_spin.py
imports: import pytest
  import pennylane
  from pennylane import Identity, PauliX, PauliY, PauliZ
  from pennylane import numpy
  from pennylane import qchem
  from pennylane.operation import enable_new_opmath, disable_new_opmath
label_desc: Use image node_id 1 for calling a global function with example usage: test_spin2_matrix_elements(n_spin_orbs, matrix_ref) without return types