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: register next-in-line part of results received from a given peer for use in iterate_output_tensors
  depending on the algorithm, processed part is an average, difference from average or another aggregation
docstr_tok: ["register","next-in-line","part","of","results","received","from","a","given","peer","for","use","in","iterate_output_tensors","depending","on","the","algorithm",",","processed","part","is","an","average",",","difference","from","average","or","another","aggregation"]
code: def register_processed_part(
      self, peer_index: int, part_index: int, part: torch.Tensor
  ):
      """
      register next-in-line part of results received from a given peer for use in iterate_output_tensors
      depending on the algorithm, processed part is an average, difference from average or another aggregation
      """
      if part_index != self._outputs_registered_by_peer[peer_index]:
          raise ValueError(
              f"Could not register part #{part_index} from peer #{peer_index}, "
              f" expected part index: {self._outputs_registered_by_peer[peer_index]}"
          )
      self._output_parts_by_peer[peer_index].append(part)
      self._outputs_registered_by_peer[peer_index] += 1
      self._output_part_available[peer_index].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 3 for calling the TensorPartContainer obj's underlying member method code with example usage: obj.register_processed_part(peer_index, part_index, part) without return types