class_docstr: Open dataset in readonly mode.
  
  `DistributeDataset` is used to read datasets in a distributed manner.
  Data in this dataset will be distributed evenly in blocks to each worker in the `distributed communicator`.
  
  **Note** When all data has been read, reading dataset again will revert back to the first data.
  
  Args:
      path (str): Path to dataset.
      rank (int): Rank in distributed communicator. See: bmtrain.rank()
      world_size (int): Total workers in distributed communicator. See: bmtrain.world_size()
      block_size (int): Size of each block in bytes. All files in the same dataset should have the same block size. Default: 16MB
  
  Example:
      >>> dataset = DistributedDataset("/path/to/dataset")
      >>> for i in range(10):
      >>>     dataset.read()
class_docstr_tok: ["Open","dataset","in","readonly","mode",".","`","DistributeDataset","`","is","used","to","read","datasets","in","a","distributed","manner",".","Data","in","this","dataset","will","be","distributed","evenly","in","blocks","to","each","worker","in","the","`","distributed","communicator","`",".","*","*","Note","*","*","When","all","data","has","been","read",",","reading","dataset","again","will","revert","back","to","the","first","data",".","Args",":","path","(","str",")",":","Path","to","dataset",".","rank","(","int",")",":","Rank","in","distributed","communicator",".","See",":","bmtrain.rank","(",")","world_size","(","int",")",":","Total","workers","in","distributed","communicator",".","See",":","bmtrain.world_size","(",")","block_size","(","int",")",":","Size","of","each","block","in","bytes",".","All","files","in","the","same","dataset","should","have","the","same","block","size",".","Default",":","16MB","Example",":",">",">",">","dataset","=","DistributedDataset","(","``","\/path\/to\/dataset","''",")",">",">",">","for","i","in","range","(","10",")",":",">",">",">","dataset.read","(",")"]
code: def __init__(
      self,
      path: str,
      rank: int = 0,
      world_size: int = 1,
      serializer: Optional[Serializer] = None,
      max_repeat_times: Optional[int] = None,
      shuffle: bool = True,
  ) -> None:
      # config
      self._path = path
      self._rank = rank
      self._world_size = world_size
      self._max_repeat_times = max_repeat_times
      self._repeat_times = 0
      self._shuffle = shuffle
  
      if serializer is None:
          serializer = PickleSerializer()
      self.serializer = serializer
  
      # dataset meta
      self._unused_block: List[int] = []
      self._file_info: List[FileInfo] = []
      self._file_ends: List[int] = []
      self._total_blocks = 0
      self._nbytes = 0
      self._nlines = 0
  
      # states
      self._curr_block = None
      self._fp = None
  
      # cache
      self._last_mod_time = 0
      self._curr_fname = None
  
      self._update_states(fast_skip=False)
      self._repeat_times += 1
  
imports: import io
  import os
  import struct
  from typing import List, Optional, Set
  import torch
  import bisect
  import bmtrain
  import json
  from .serializer import Serializer, PickleSerializer
  import random
  import string
  import time
label_desc: Use image node_id 1 to create a new DistributedDataset object  with example: obj = DistributedDataset(path, rank, world_size, serializer, max_repeat_times, shuffle)