class_docstr: Auxiliary data structure for averaging, responsible for splitting tensors into parts and reassembling them.
  The class is designed to avoid excessive memory allocation and run all heavy computation in background
  
  :param tensors: local tensors to be split and aggregated
  :param peer_fractions: for each peer, a target fraction of vector elements that this peer should average
  :param compression: optionally compress tensors with this compression algorithm before sending them to peers
  :param part_size_bytes: greedily split tensors into parts of up to this many bytes (after compression)
  :param tensor_infos: CompressionInfo for each respective tensor; this determines how the tensor will be compressed
  :param return_deltas: if True, output tensors are differences (aggregated tensor - local tensor)
  :param prefetch: when compressing, pre-compute this many compressed tensors in background
class_docstr_tok: ["Auxiliary","data","structure","for","averaging",",","responsible","for","splitting","tensors","into","parts","and","reassembling","them",".","The","class","is","designed","to","avoid","excessive","memory","allocation","and","run","all","heavy","computation","in","background",":","param","tensors",":","local","tensors","to","be","split","and","aggregated",":","param","peer_fractions",":","for","each","peer",",","a","target","fraction","of","vector","elements","that","this","peer","should","average",":","param","compression",":","optionally","compress","tensors","with","this","compression","algorithm","before","sending","them","to","peers",":","param","part_size_bytes",":","greedily","split","tensors","into","parts","of","up","to","this","many","bytes","(","after","compression",")",":","param","tensor_infos",":","CompressionInfo","for","each","respective","tensor",";","this","determines","how","the","tensor","will","be","compressed",":","param","return_deltas",":","if","True",",","output","tensors","are","differences","(","aggregated","tensor","-","local","tensor",")",":","param","prefetch",":","when","compressing",",","pre-compute","this","many","compressed","tensors","in","background"]
docstr: terminate all iterators, delete intermediate data
docstr_tok: ["terminate","all","iterators",",","delete","intermediate","data"]
code: def finalize(self):
      """terminate all iterators, delete intermediate data"""
      if not self.finished.is_set():
          for peer_index in range(self.group_size):
              self._inputs_consumed_by_peer[peer_index] = True
              self._output_part_available[peer_index].set()
              self._input_parts_by_peer[peer_index].clear()
              self._output_parts_by_peer[peer_index].clear()
          if self.failed_size != 0:
              logger.warning(
                  f"Averaging: received {(1. - self.failed_size / self.total_size) * 100:.1f}% results"
              )
          self._outputs_consumed = True
          self.finished.set()
  
imports: import asyncio
  from collections import deque
  from typing import AsyncIterable, AsyncIterator, Optional, Sequence, Tuple, TypeVar
  import numpy
  import torch
  from hivemind.compression import CompressionBase, CompressionInfo, NoCompression
  from hivemind.proto import runtime_pb2
  from hivemind.utils import amap_in_executor, as_aiter, get_logger
label_desc: Use image node_id 6 for calling the TensorPartContainer obj's underlying member method code with example usage: obj.finalize() without return types