code: def test_memmap_roundtrip(tmpdir):
      for i, arr in enumerate(basic_arrays + record_arrays):
          if arr.dtype.hasobject:
              # Skip these since they can't be mmap'ed.
              continue
          # Write it out normally and through mmap.
          nfn = os.path.join(tmpdir, f"normal{i}.npy")
          mfn = os.path.join(tmpdir, f"memmap{i}.npy")
          with open(nfn, "wb") as fp:
              format.write_array(fp, arr)
  
          fortran_order = (
              arr.flags.f_contiguous and not arr.flags.c_contiguous
          )
          ma = format.open_memmap(
              mfn,
              mode="w+",
              dtype=arr.dtype,
              shape=arr.shape,
              fortran_order=fortran_order,
          )
          ma[...] = arr
          ma.flush()
  
          # Check that both of these files' contents are the same.
          with open(nfn, "rb") as fp:
              normal_bytes = fp.read()
          with open(mfn, "rb") as fp:
              memmap_bytes = fp.read()
          assert_equal_(normal_bytes, memmap_bytes)
  
          # Check that reading the file using memmap works.
          ma = format.open_memmap(nfn, mode="r")
          ma.flush()
  
imports: import sys
  import os
  import warnings
  import pytest
  from io import BytesIO
  import numpy
  from numpy.testing import assert_, assert_array_equal, assert_raises, assert_raises_regex, assert_warns, IS_PYPY, IS_WASM
  from numpy.testing._private.utils import requires_memory
  from numpy.lib import format
label_desc: Use image node_id 9 for calling a global function with example usage: test_memmap_roundtrip(tmpdir) without return types