class_docstr: This custom DataLoader serves mini-batches that are either fully-observed (i.e. labeled)
  or partially-observed (i.e. unlabeled) but never mixed.
class_docstr_tok: ["This","custom","DataLoader","serves","mini-batches","that","are","either","fully-observed","(","i.e",".","labeled",")","or","partially-observed","(","i.e",".","unlabeled",")","but","never","mixed","."]
code: def __init__(
      self, data_x, data_y, batch_size, num_classes=4, missing_label=-1
  ):
      super().__init__()
      self.data_x = data_x
      self.data_y = data_y
      self.batch_size = batch_size
      self.num_classes = num_classes
  
      self.unlabeled = torch.where(data_y == missing_label)[0]
      self.num_unlabeled = self.unlabeled.size(0)
      self.num_unlabeled_batches = math.ceil(
          self.num_unlabeled / self.batch_size
      )
  
      self.labeled = torch.where(data_y != missing_label)[0]
      self.num_labeled = self.labeled.size(0)
      self.num_labeled_batches = math.ceil(
          self.num_labeled / self.batch_size
      )
  
      assert self.data_x.size(0) == self.data_y.size(0)
      assert len(self) > 0
  
file_path: pyro/pyro/contrib/examples/scanvi_data.py
imports: import math
  import numpy
  import torch
  import torch.nn
  from scipy import sparse
label_desc: Use image node_id 1 to create a new BatchDataLoader object from inherited base classes: object with example: obj = BatchDataLoader(data_x, data_y, batch_size, num_classes, missing_label)