docstr: Create the data loader
  
  Reference: https://pytorch.org/docs/stable/data.html#torch.utils.data.Sampler
  
  Args:
      dataset (Dataset): dataset from which to load the data.
      batch_size (int): how many samples per batch to load
docstr_tok: ["Create","the","data","loader","Reference",":","https",":","\/\/pytorch.org\/docs\/stable\/data.html","#","torch.utils.data.Sampler","Args",":","dataset","(","Dataset",")",":","dataset","from","which","to","load","the","data",".","batch_size","(","int",")",":","how","many","samples","per","batch","to","load"]
code: def create_loader(self, dataset, batch_size):
      """Create the data loader
  
      Reference: https://pytorch.org/docs/stable/data.html#torch.utils.data.Sampler
  
      Args:
          dataset (Dataset): dataset from which to load the data.
          batch_size (int): how many samples per batch to load
      """
      if self._balance:
          sampler = BalancedBatchSampler(dataset, batch_size=batch_size)
      elif self._class_weights is not None:
          sampler = ReweightedBatchSampler(
              dataset,
              batch_size=batch_size,
              class_weights=self._class_weights,
          )
      elif self._balance_domain:
          sampler = DomainBalancedBatchSampler(
              dataset, batch_size=batch_size
          )
      else:
          if len(dataset) < batch_size:
              sub_sampler = RandomSampler(
                  dataset, replacement=True, num_samples=batch_size
              )
          else:
              sub_sampler = RandomSampler(dataset)
          sampler = BatchSampler(
              sub_sampler, batch_size=batch_size, drop_last=True
          )
      return torch.utils.data.DataLoader(
          dataset=dataset, batch_sampler=sampler
      )
  
imports: import logging
  import numpy
  import torch.utils.data
  import torchvision
  from torch.utils.data.sampler import BatchSampler, RandomSampler
label_desc: Use image node_id 2 for calling the SamplingConfig obj's underlying member method code with example usage: obj.create_loader(dataset, batch_size) and returns: torch