code: def test_mapwrapper_parallel():
      in_arg = np.arange(10.0)
      out_arg = np.sin(in_arg)
  
      with MapWrapper(2) as p:
          out = p(np.sin, in_arg)
          assert_equal(list(out), out_arg)
  
          assert_(p._own_pool is True)
          assert_(isinstance(p.pool, PWL))
          assert_(p._mapfunc is not None)
  
      # the context manager should've closed the internal pool
      # check that it has by asking it to calculate again.
      with assert_raises(Exception) as excinfo:
          p(np.sin, in_arg)
  
      assert_(excinfo.type is ValueError)
  
      # can also set a PoolWrapper up with a map-like callable instance
      with Pool(2) as p:
          q = MapWrapper(p.map)
  
          assert_(q._own_pool is False)
          q.close()
  
          # closing the PoolWrapper shouldn't close the internal pool
          # because it didn't create it
          out = p.map(np.sin, in_arg)
          assert_equal(list(out), out_arg)
  
imports: from multiprocessing import Pool
  from multiprocessing.pool import Pool
  import re
  import math
  from fractions import Fraction
  import numpy
  from numpy.testing import assert_equal, assert_
  import pytest
  from pytest import raises
  import hypothesis.extra.numpy
  from hypothesis import given, strategies, reproduce_failure
  from scipy.conftest import array_api_compatible
  from scipy._lib._array_api import xp_assert_equal
  from scipy._lib._util import _aligned_zeros, check_random_state, MapWrapper, getfullargspec_no_self, FullArgSpec, rng_integers, _validate_int, _rename_parameter, _contains_nan, _rng_html_rewrite, _lazywhere
label_desc: Use image node_id 6 for calling a global function with example usage: test_mapwrapper_parallel() without return types