docstr: Apply all updates in-place.
docstr_tok: ["Apply","all","updates","in-place","."]
code: def flush(self, mode: "_modes.Mode") -> None:
      """Apply all updates in-place."""
      if len(self.updates) == 0:
          return
  
      if isinstance(self.array, _ArrayPlaceholder):
          dtype = self.updates[0][0].array.dtype
          self.array = self.array.to_ndarray(mode, dtype)
  
      with self.on_ready() as stream:
          for update_data, idx in self.updates:
              stream.wait_event(update_data.ready)
              if mode is _modes.REPLICA:
                  self.array[idx] = update_data.array
              else:
                  self.array[idx] = mode.func(
                      self.array[idx], update_data.array
                  )
  
          stream.record(self.ready)
          self.prevent_gc = (self.prevent_gc, self.updates)
          self.updates = []
  
imports: import contextlib
  from itertools import chain
  from typing import Any, Iterator, Optional, Union
  import numpy
  from cupy._core.core import ndarray
  import cupy._creation.basic
  import cupy._manipulation.dims
  from cupy.cuda.device import Device
  from cupy.cuda.stream import Event
  from cupy.cuda.stream import Stream
  from cupy.cuda.stream import get_current_stream
  from cupyx.distributed.array import _modes
  from cupyx.distributed.array import _index_arith
  from cupyx.distributed.array import _data_transfer
  from cupyx.distributed.array._data_transfer import _Communicator
label_desc: Use image node_id 6 for calling the _Chunk obj's underlying member method code with example usage: obj.flush(mode) without return types