code: def __iter__(self):
      #  With IterableDataset, the same __iter__ is copied over to the multiple workers of
      #  a Dataloader. Hence, we need to configure the __iter__ to not yield duplicated data
      #  when more than 1 workers are used.
      #
      #  To avoid duplicates, we need to split the input dicts between the workers.
      #  The grouper() converts a dict generator given as input and yields only the
      #  dicts that are to be processed by the given worker_id.
      #
      #  For instance, consider input as [dictA, dictB, dictC, ...], then the grouper
      #  (with n=2) will return, [[dictA, dictB], [dictE, dictF] ...] for worker 1 and
      #  [[dictC, dictD], [dictG, dictH] ...] for worker 2.
  
      worker_info = torch.utils.data.get_worker_info()
      if self.distributed:
          worker_id = (
              self.rank * worker_info.num_workers + worker_info.id
          )
          total_workers = self.world_size * worker_info.num_workers
      else:
          worker_id = worker_info.id
          total_workers = self.dataloader_workers
  
      dicts = grouper(
          self.file_to_dicts_generator,
          n=10,
          worker_id=worker_id,
          total_workers=total_workers,
      )
      results = map(self._dataset_from_chunk, dicts)
  
      batch = []
      for datasets, tensor_names in results:
          if not datasets:
              continue
          self.tensor_names = tensor_names
          for ds in datasets:
              batch.append(ds)
              if len(batch) == self.batch_size:
                  yield batch
                  batch = []
      if batch:
          yield batch
  
imports: import copy
  import logging
  import torch.multiprocessing
  from contextlib import ExitStack
  from functools import partial
  import random
  from pathlib import Path
  from itertools import chain, groupby
  import numpy
  from sklearn.utils.class_weight import compute_class_weight
  from torch.utils.data import Dataset, Subset, IterableDataset
  from torch.utils.data.distributed import DistributedSampler
  from torch.utils.data.sampler import RandomSampler, SequentialSampler
  import torch
  from sklearn.model_selection import StratifiedKFold, KFold, ShuffleSplit, StratifiedShuffleSplit
  from tqdm import tqdm
  from farm.data_handler.dataloader import NamedDataLoader
  from farm.data_handler.processor import Processor, BertStyleLMProcessor
  from farm.data_handler.utils import grouper
  from farm.data_handler.dataset import ConcatTensorDataset
  from farm.modeling.tokenization import EmbeddingTokenizer
  from farm.utils import MLFlowLogger
  from farm.utils import log_ascii_workers, calc_chunksize
  from farm.utils import get_dict_checksum
  from farm.visual.ascii.images import TRACTOR_SMALL
label_desc: Use image node_id 3 for calling the _StreamingDataSet obj's underlying member method code with example usage: obj.__iter__() without return types