class_docstr: A buffer for P2P shuffle
  
  The objects to buffer are typically bytes belonging to certain shards.
  Typically the buffer is implemented on sending and receiving end.
  
  The buffer allows for concurrent writing and buffers shards to reduce overhead of writing.
  
  The shards are typically provided in a format like::
  
      {
          "bucket-0": [b"shard1", b"shard2"],
          "bucket-1": [b"shard1", b"shard2"],
      }
  
  Buckets typically correspond to output partitions.
  
  If exceptions occur during writing, the buffer is automatically closed. Subsequent attempts to write will raise the same exception.
  Flushing will not raise an exception. To ensure that the buffer finished successfully, please call `ShardsBuffer.raise_on_exception`
class_docstr_tok: ["A","buffer","for","P2P","shuffle","The","objects","to","buffer","are","typically","bytes","belonging","to","certain","shards",".","Typically","the","buffer","is","implemented","on","sending","and","receiving","end",".","The","buffer","allows","for","concurrent","writing","and","buffers","shards","to","reduce","overhead","of","writing",".","The","shards","are","typically","provided","in","a","format","like",":",":","{","``","bucket-0","''",":","[","b","''","shard1","''",",","b","''","shard2","''","]",",","``","bucket-1","''",":","[","b","''","shard1","''",",","b","''","shard2","''","]",",","}","Buckets","typically","correspond","to","output","partitions",".","If","exceptions","occur","during","writing",",","the","buffer","is","automatically","closed",".","Subsequent","attempts","to","write","will","raise","the","same","exception",".","Flushing","will","not","raise","an","exception",".","To","ensure","that","the","buffer","finished","successfully",",","please","call","`","ShardsBuffer.raise_on_exception","`"]
code: def read(self, id: str) -> ShardType:
      raise NotImplementedError()
  
file_path: distributed/distributed/shuffle/_buffer.py
imports: from __future__ import annotations
  import abc
  import asyncio
  import logging
  from collections import defaultdict
  from collections.abc import Sized
  from typing import TYPE_CHECKING, Any, Generic, TypeVar
  from distributed.metrics import context_meter, time
  from distributed.shuffle._limiter import ResourceLimiter
  from distributed.sizeof import sizeof
label_desc: Use image node_id 3 for calling the ShardsBuffer obj's underlying member method code with example usage: obj.read(id) without return types