class_docstr: RandomizedBatchSamplerIterator randomly samples from each dataset
  using the provided weights.
  
  By default, the iterator stops after all datasets are exhausted. This can be changed
  by setting another stopping mechanism.
  
  Returns batches of the format: {dataloader_name: batch_from_dataloader}
  
  Args:
      individual_dataloaders (Mapping[str, Union[DataLoader, Iterable]]): A mapping of DataLoaders or Iterables with dataloader name as key
      and dataloader/iterable object as value.
      iteration_strategy (RandomizedBatchSampler): A RandomizedBatchSampler dataclass indicating how the dataloaders are iterated over.
  
  Examples:
      >>> loaders = {'a': torch.utils.data.DataLoader(range(4), batch_size=4),
          'b': torch.utils.data.DataLoader(range(15), batch_size=5)}
      >>> randomized_batch_sampler = RandomizedBatchSampler(
              stopping_mechanism=StoppingMechanism.ALL_DATASETS_EXHAUSTED
          )
      >>> combined_iterator = RandomizedBatchSamplerIterator(loaders, randomized_batch_sampler)
      >>> for item in combined_iterator:
              print(item)
      {'b': tensor([0, 1, 2, 3, 4])}
      {'b': tensor([5, 6, 7, 8, 9])}
      {'a': tensor([0, 1, 2, 3])}
      {'b': tensor([10, 11, 12, 13, 14])}
code: def __init__(
      self,
      # pyre-fixme[24]: Generic type `Iterable` expects 1 type parameter
      individual_dataloaders: Mapping[str, Union[DataLoader, Iterable]],
      iteration_strategy: RandomizedBatchSampler,
  ) -> None:
      super().__init__(individual_dataloaders, iteration_strategy)
      self._iteration_strategy = iteration_strategy
      self._individual_dataloaders = individual_dataloaders
      self._individual_iterators: MutableMapping[
          str, Iterator[DataLoader]
      ] = {
          name: iter(dl)
          for name, dl in self._individual_dataloaders.items()
      }
      self._iterator_names: List[str] = sorted(
          self._individual_dataloaders.keys()
      )
      weights = iteration_strategy.weights
      if weights is None:
          self._iterator_weights: Optional[List[float]] = None
      else:
          assert set(self._iterator_names).issubset(
              weights.keys()
          ), "Weight keys must match dataloader keys"
          self._iterator_weights = [
              float(weights[name]) for name in self._iterator_names
          ]
      self._iterator_is_exhausted: List[bool] = [False] * len(
          self._iterator_names
      )
      self.stopping_mechanism: Optional[
          StoppingMechanism
      ] = iteration_strategy.stopping_mechanism
      self.enforce_same_loader_across_ranks: bool = (
          iteration_strategy.enforce_same_loader_across_ranks
      )
      if self.enforce_same_loader_across_ranks:
          self._iterator_names_dict: Dict[str, torch.IntTensor] = {
              name: torch.IntTensor([idx])
              for idx, name in enumerate(self._iterator_names)
          }
          # pyre-ignore[4]: missing attribute annotation
          self._process_group = dist.new_group(
              backend="gloo", ranks=None
          )
  
      self._iterators_finished: List[str] = []
  
imports: from __future__ import annotations
  import random
  from abc import abstractmethod
  from dataclasses import dataclass
  from enum import Enum
  from itertools import cycle
  from typing import Any, Dict, Iterable, Iterator, List, Mapping, MutableMapping, Optional, Type, TYPE_CHECKING, Union
  import torch
  import torch.distributed
label_desc: Use image node_id 1 to create a new RandomizedBatchSamplerIterator object from inherited base classes: MultiIterator with example: obj = RandomizedBatchSamplerIterator(individual_dataloaders, iteration_strategy)