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 _open_file(self, fname, offset):
      if self._curr_fname != fname:
          if self._fp is not None:
              self._fp.close()
              self._curr_fname = None
          # self._fp = open(self._get_file_path(fname), "rb")
          self._fp = SafeFile(self._get_file_path(fname), "rb")
          self._curr_fname = fname
      else:
          assert self._fp is not None, "Unexpected error"
      self._fp.seek(offset, io.SEEK_SET)
  
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 11 for calling the DistributedDataset obj's underlying member method code with example usage: obj._open_file(fname, offset) without return types