code: def _pack(data, mem, offset, limit):
      if len(mem) == 0:
          return data
      t = type(data)
      over = False
      if t is tuple or t is list:
          ret = []
          for v in data:
              if isinstance(v, numpy.ndarray):
                  if v.nbytes + offset > limit:
                      over = True
                  else:
                      v = _PackedNdarray(v, mem, offset)
                      offset += v.nbytes
              ret.append(v)
          data = t(ret)
      elif t is dict:
          ret = {}
          for k, v in six.iteritems(data):
              if isinstance(v, numpy.ndarray):
                  if v.nbytes + offset > limit:
                      over = True
                  else:
                      v = _PackedNdarray(v, mem, offset)
                      offset += v.nbytes
              ret[k] = v
          data = ret
      elif t is numpy.ndarray:
          if data.nbytes + offset > limit:
              over = True
          else:
              data = _PackedNdarray(data, mem, offset)
              offset += data.nbytes
      if over:
          expect = _measure(data)
          warnings.warn(
              "Shared memory size is too small.\n"
              + "Please set shared_mem option for MultiprocessIterator.\n"
              + "Expect shared memory size: {} bytes.\n".format(expect)
              + "Actual shared memory size: {} bytes.".format(
                  limit - offset
              ),
              UserWarning,
          )
      return data
  
imports: from __future__ import division
  import datetime
  import multiprocessing
  from multiprocessing import sharedctypes
  import signal
  import sys
  import threading
  import warnings
  import numpy
  import six
  from chainer.dataset import iterator
  from chainer.iterators import _statemachine
  from chainer.iterators.order_samplers import ShuffleOrderSampler
label_desc: Use image node_id 6 for calling a global function with example usage: _pack(data, mem, offset, limit) and returns: data, data