code: def pack_params(
      params, attr_name, buffer, transfer_dtype, zero_fill, stream=None
  ):
      if len(params) == 0:
          return
  
      # NOTE: dtypes of params might be mixed, in particular f16 & f32.
      offset = 0
      for param in params:
          v = getattr(param, attr_name)
          if attr_name == "grad" and v is None and zero_fill:
              v = param.xp.zeros_like(param.data)
          size = v.size * np.dtype(transfer_dtype).itemsize
          if v.dtype != transfer_dtype:
              tmp = v.astype(transfer_dtype)
              buffer.from_device(tmp, size, offset, stream)
          else:
              buffer.from_device(v, size, offset, stream)
  
          offset += size
  
imports: import ctypes
  import mpi4py.MPI
  import numpy
  from chainermn.communicators import _communication_utility
  import chainer.backends
  import chainerx
label_desc: Use image node_id 5 for calling a global function with example usage: pack_params(params, attr_name, buffer, transfer_dtype, zero_fill, stream) without return types