class_docstr: Create an iterator that will alternate between two dataloaders.
  
  Args:
      dl_1 (DataLoader): first DataLoader
      dl_2 (DataLoader): second DataLoader
      num_steps (Optional[int]): Number of steps, if None will be the sum of both length.
      p (Optional[float]): Probability of choosing dl_1 over dl_2.
          If None, will be alternate between the two.
class_docstr_tok: ["Create","an","iterator","that","will","alternate","between","two","dataloaders",".","Args",":","dl_1","(","DataLoader",")",":","first","DataLoader","dl_2","(","DataLoader",")",":","second","DataLoader","num_steps","(","Optional","[","int","]",")",":","Number","of","steps",",","if","None","will","be","the","sum","of","both","length",".","p","(","Optional","[","float","]",")",":","Probability","of","choosing","dl_1","over","dl_2",".","If","None",",","will","be","alternate","between","the","two","."]
code: def __init__(
      self,
      dl_1: DataLoader,
      dl_2: Optional[DataLoader],
      num_steps: Optional[int] = None,
      p: Optional[float] = None,
  ):
      self.dl_1 = dl_1
      self.dl_1_iter = cycle(dl_1)
      self.len_dl1 = len(dl_1)
  
      if dl_2 is not None:  # Avoid error if p=1
          self.dl_2 = dl_2
          self.dl_2_iter = cycle(dl_2)
          self.len_dl2 = len(dl_2)
      else:
          p = 1
          self.len_dl2 = 2
  
      self.num_steps: Optional[int] = num_steps or (
          self.len_dl1 + self.len_dl2
      )
      self.p: Optional[Tuple[float, float]] = (
          None if p is None else (p, 1 - p)
      )
      self._iter_idx = None
  
file_path: baal/baal/utils/ssl_iterator.py
imports: from itertools import cycle
  from typing import Optional, Union, Dict, Sequence, Tuple
  import numpy
  from baal.active import ActiveLearningDataset
  from torch.utils.data import DataLoader
label_desc: Use image node_id 1 to create a new AlternateIterator object  with example: obj = AlternateIterator(dl_1, dl_2, num_steps, p)