code: def copy_to_mmap_record_array(
      source: numpy.ndarray,
      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 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 = source[start:stop]
          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 10 for calling a global function with example usage: copy_to_mmap_record_array(source, target, fields, chunksize) without return types