code: def copy_mmap_record_arrays(
      source: numpy.memmap,
      target: numpy.memmap,
      fields: list[str],
      chunksize: int = 100000,
  ) -> None:
      """
      Writing into a memmapped array allocates memory equivalent to the
      amount that you are writing. With big arrays this is undesirable
      so we write in chunks
      """
      assert source.filename is not None
      assert target.filename is not None
  
      start = 0
      stops = itertools.chain(
          range(chunksize, source.size, chunksize), [source.size]
      )
      for stop in stops:
          shape = (stop - start,)
          source_slice: numpy.memmap = numpy.memmap(
              source.filename,
              dtype=source.dtype,
              offset=(start * source.dtype.itemsize),
              shape=shape,
          )
          target_slice: numpy.memmap = numpy.memmap(
              target.filename,
              dtype=target.dtype,
              offset=(start * target.dtype.itemsize),
              shape=shape,
          )
          target_slice[fields] = source_slice[fields]
  
          start = stop
  
imports: from __future__ import annotations
  import array
  import itertools
  import logging
  import tempfile
  from collections import defaultdict
  from typing import Generator, Iterable, Sequence, cast
  import numpy
  import numpy.typing
  import scipy.cluster.hierarchy
  from dedupe._typing import ArrayLinks, Clusters, RecordID, Scores, TupleLinks
label_desc: Use image node_id 11 for calling a global function with example usage: copy_mmap_record_arrays(source, target, fields, chunksize) without return types