class_docstr: Implements manual distributed sharding (MDS).
class_docstr_tok: ["Implements","manual","distributed","sharding","(","MDS",")","."]
code: def _read(self, file_path):
      start_index = 0
      step_size = 1
      if common_util.is_distributed():
          start_index += dist.get_rank()
          step_size *= dist.get_world_size()
      for i in islice(
          range(TOTAL_INSTANCES), start_index, None, step_size
      ):
          yield self.text_to_instance(i)
  
imports: from itertools import islice
  from typing import Optional, List, Set
  import pytest
  import torch.distributed
  from allennlp.common import util
  from allennlp.data import Instance
  from allennlp.data.dataset_readers import DatasetReader, WorkerInfo
  from allennlp.data.fields import LabelField
label_desc: Use image node_id 2 for calling the MockMdsDatasetReader obj's underlying member method code with example usage: obj._read(file_path) without return types