class_docstr: Iterator for alternating between labeled and un-labled dataloaders
  for semi-supervised learning.
  
  Args:
      al_dataset (ActiveLearningDataset): dataset and pool from which to load data.
      batch_size (int):  how many samples per batch to load.
      num_steps (int): number of steps before the end of the iterator.
      p (Optional[float]): probability of selecting a labeled batch.
          If None, the batches alternate.
      shuffle (Optional[bool]): set to ``True`` to have the data reshuffled at every epoch.
      num_workers (Optional[int]): how many subprocesses to use for data loading.
      drop_last (Optional[bool]): set to ``True`` to drop the last incomplete batch.
class_docstr_tok: ["Iterator","for","alternating","between","labeled","and","un-labled","dataloaders","for","semi-supervised","learning",".","Args",":","al_dataset","(","ActiveLearningDataset",")",":","dataset","and","pool","from","which","to","load","data",".","batch_size","(","int",")",":","how","many","samples","per","batch","to","load",".","num_steps","(","int",")",":","number","of","steps","before","the","end","of","the","iterator",".","p","(","Optional","[","float","]",")",":","probability","of","selecting","a","labeled","batch",".","If","None",",","the","batches","alternate",".","shuffle","(","Optional","[","bool","]",")",":","set","to","``","True","``","to","have","the","data","reshuffled","at","every","epoch",".","num_workers","(","Optional","[","int","]",")",":","how","many","subprocesses","to","use","for","data","loading",".","drop_last","(","Optional","[","bool","]",")",":","set","to","``","True","``","to","drop","the","last","incomplete","batch","."]
docstr:     Check if batch returned from SemiSupervisedIterator is labeled.
  
  Args:
      batch (Union[Dict, Sequence]): batch to check
  
  Returns:
      bool, if batch is labeled.
  
  Raises:
      ValueError if we can't process the batch type.
docstr_tok: ["Check","if","batch","returned","from","SemiSupervisedIterator","is","labeled",".","Args",":","batch","(","Union","[","Dict",",","Sequence","]",")",":","batch","to","check","Returns",":","bool",",","if","batch","is","labeled",".","Raises",":","ValueError","if","we","ca","n't","process","the","batch","type","."]
code: def is_labeled(batch: Union[Dict, Sequence]) -> bool:
      """
          Check if batch returned from SemiSupervisedIterator is labeled.
  
      Args:
          batch (Union[Dict, Sequence]): batch to check
  
      Returns:
          bool, if batch is labeled.
  
      Raises:
          ValueError if we can't process the batch type.
      """
      if isinstance(batch, dict):
          return batch[SemiSupervisedIterator.IS_LABELED_TAG]
      elif isinstance(batch, tuple):
          item, idx = batch
          return idx == 0
      else:
          raise ValueError(f"Unknown type: {type(batch)}")
  
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 3 for calling the SemiSupervisedIterator obj's underlying member method code with example usage: obj.is_labeled(batch) and returns: batch, unknown