code: def _all_reduce_intersections(
      op_mode: "_modes._OpMode",
      shape: tuple[int, ...],
      chunk_map: dict[int, list[_Chunk]],
      comms: dict[int, _Communicator],
      streams: dict[int, Stream],
  ) -> None:
      chunks_list = list(chain.from_iterable(chunk_map.values()))
  
      for i in range(len(chunks_list)):
          src_chunk = chunks_list[i]
          src_chunk.flush(op_mode)
  
          for j in range(i + 1, len(chunks_list)):
              dst_chunk = chunks_list[j]
  
              src_chunk.apply_to(
                  dst_chunk, op_mode, shape, comms, streams
              )
  
      for j in range(len(chunks_list) - 1, -1, -1):
          src_chunk = chunks_list[j]
          src_chunk.flush(_modes.REPLICA)
  
          for i in range(j):
              dst_chunk = chunks_list[i]
              src_chunk.apply_to(
                  dst_chunk, _modes.REPLICA, shape, comms, streams
              )
  
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 1 for calling a global function with example usage: _all_reduce_intersections(op_mode, shape, chunk_map, comms, streams) without return types