code: def test_2d_cos():
      nchan = 8
      res = 10
      npix = res * res
      bds = [-1, 1]
      sz = 2
      s = InvertedEncoding2D(
          stim_xlim=bds,
          stim_ylim=bds,
          stimulus_resolution=res,
          channels=np.random.rand(nchan, npix),
      )
      sz = s._2d_cosine_fwhm_to_sz(1)
      fcn = s._make_2d_cosine(
          s.xp.reshape(-1, 1),
          s.yp.reshape(-1, 1),
          np.linspace(bds[0], bds[1], nchan),
          np.linspace(bds[0], bds[1], nchan),
          sz,
      )
      assert fcn.shape == (nchan, npix)
      # Test that masking works -- basis function should have fewer non-zero
      # elements than specified by the size constant
      xd = np.diff(s.xp)[0][0]
      nval = (np.nonzero(fcn[0, :])[0]).size
      assert nval * (xd**2) <= sz**2
  
imports: import pytest
  import numpy
  import logging
  from brainiak.reconstruct.iem import InvertedEncoding1D, InvertedEncoding2D
  from brainiak.utils.fmrisim import generate_1d_gaussian_rfs, generate_1d_rf_responses
  from scipy.stats import circmean
label_desc: Use image node_id 10 for calling a global function with example usage: test_2d_cos() without return types