code: def write_bin(file, binary, buffer=None, append=True):
      """
      Writes binary array to file.
  
      Parameters
      ----------
      file : str
          A string of filename to store output.
      binary : ndarray
          Binary array to be written to file.
      buffer : ndarray, optional
          Pinned memory buffer to use when copying data from GPU.
      append : bool, optional
          Append to file if created.
  
      Returns
      -------
      out : ndarray
          An 1-dimensional array containing binary data.
  
      """
  
      # Get current stream, default or not.
      stream = cp.cuda.get_current_stream()
  
      if buffer is None:
          buffer = cp.asnumpy(binary)
      else:
          binary.get(out=buffer)
  
      if append is True:
          mode = "ab"
      else:
          mode = "wb"
  
      with open(file, mode) as f:
          stream.synchronize()
          buffer.tofile(f)
  
imports: import cupy
  from ._writer_cuda import _pack
label_desc: Use image node_id 1 for calling a global function with example usage: write_bin(file, binary, buffer, append) without return types