code: def frame_split_size(
      frame: bytes | memoryview, n: int = BIG_BYTES_SHARD_SIZE
  ) -> list[memoryview]:
      """
      Split a frame into a list of frames of maximum size
  
      This helps us to avoid passing around very large bytestrings.
  
      Examples
      --------
      >>> frame_split_size([b'12345', b'678'], n=3)  # doctest: +SKIP
      [b'123', b'45', b'678']
      """
      n = n or BIG_BYTES_SHARD_SIZE
      frame = memoryview(frame)
  
      if frame.nbytes <= n:
          return [frame]
  
      nitems = frame.nbytes // frame.itemsize
      items_per_shard = n // frame.itemsize
  
      return [
          frame[i : i + items_per_shard]
          for i in range(0, nitems, items_per_shard)
      ]
  
file_path: distributed/distributed/protocol/utils.py
imports: from __future__ import annotations
  import ctypes
  import struct
  from collections.abc import Collection, Iterable, Sequence
  from typing import Literal, overload
  import dask
  from distributed.utils import nbytes
label_desc: Use image node_id 2 for calling a global function with example usage: frame_split_size(frame, n) and returns: unknown, list