class_docstr: Few-shot learning is an important scenario for prompt-learning, this is a sampler that samples few examples over each class.
  
  Args:
      num_examples_total(:obj:`int`, optional): Sampling strategy ``I``: Use total number of examples for few-shot sampling.
      num_examples_per_label(:obj:`int`, optional): Sampling strategy ``II``: Use the number of examples for each label for few-shot sampling.
      also_sample_dev(:obj:`bool`, optional): Whether to apply the sampler to the dev data.
      num_examples_total_dev(:obj:`int`, optional): Sampling strategy ``I``: Use total number of examples for few-shot sampling.
      num_examples_per_label_dev(:obj:`int`, optional): Sampling strategy ``II``: Use the number of examples for each label for few-shot sampling.
class_docstr_tok: ["Few-shot","learning","is","an","important","scenario","for","prompt-learning",",","this","is","a","sampler","that","samples","few","examples","over","each","class",".","Args",":","num_examples_total","(",":","obj",":","`","int","`",",","optional",")",":","Sampling","strategy","``","I","``",":","Use","total","number","of","examples","for","few-shot","sampling",".","num_examples_per_label","(",":","obj",":","`","int","`",",","optional",")",":","Sampling","strategy","``","II","``",":","Use","the","number","of","examples","for","each","label","for","few-shot","sampling",".","also_sample_dev","(",":","obj",":","`","bool","`",",","optional",")",":","Whether","to","apply","the","sampler","to","the","dev","data",".","num_examples_total_dev","(",":","obj",":","`","int","`",",","optional",")",":","Sampling","strategy","``","I","``",":","Use","total","number","of","examples","for","few-shot","sampling",".","num_examples_per_label_dev","(",":","obj",":","`","int","`",",","optional",")",":","Sampling","strategy","``","II","``",":","Use","the","number","of","examples","for","each","label","for","few-shot","sampling","."]
docstr: The ``__call__`` function of the few-shot sampler.
  
  Args:
      train_dataset (:obj:`Union[Dataset, List]`): The train dataset for the sampler.
      valid_dataset (:obj:`Union[Dataset, List]`, optional): The valid dataset for the sampler. Default to None.
      seed (:obj:`int`, optional): The random seed for the sampling.
  
  Returns:
      :obj:`(Union[Dataset, List], Union[Dataset, List])`: The sampled dataset (train_dataset, valid_dataset), whose type is identical to the input.
docstr_tok: ["The","``","__call__","``","function","of","the","few-shot","sampler",".","Args",":","train_dataset","(",":","obj",":","`","Union","[","Dataset",",","List","]","`",")",":","The","train","dataset","for","the","sampler",".","valid_dataset","(",":","obj",":","`","Union","[","Dataset",",","List","]","`",",","optional",")",":","The","valid","dataset","for","the","sampler",".","Default","to","None",".","seed","(",":","obj",":","`","int","`",",","optional",")",":","The","random","seed","for","the","sampling",".","Returns",":",":","obj",":","`","(","Union","[","Dataset",",","List","]",",","Union","[","Dataset",",","List","]",")","`",":","The","sampled","dataset","(","train_dataset",",","valid_dataset",")",",","whose","type","is","identical","to","the","input","."]
code: def __call__(
      self,
      train_dataset: Union[Dataset, List],
      valid_dataset: Optional[Union[Dataset, List]] = None,
      seed: Optional[int] = None,
  ) -> Union[Dataset, List]:
      """
      The ``__call__`` function of the few-shot sampler.
  
      Args:
          train_dataset (:obj:`Union[Dataset, List]`): The train dataset for the sampler.
          valid_dataset (:obj:`Union[Dataset, List]`, optional): The valid dataset for the sampler. Default to None.
          seed (:obj:`int`, optional): The random seed for the sampling.
  
      Returns:
          :obj:`(Union[Dataset, List], Union[Dataset, List])`: The sampled dataset (train_dataset, valid_dataset), whose type is identical to the input.
  
      """
      if valid_dataset is None:
          if self.also_sample_dev:
              return self._sample(
                  train_dataset, seed, sample_twice=True
              )
          else:
              return self._sample(
                  train_dataset, seed, sample_twice=False
              )
      else:
          train_dataset = self._sample(train_dataset, seed)
          if self.also_sample_dev:
              valid_dataset = self._sample(
                  valid_dataset, seed, is_dev=True
              )
          return train_dataset, valid_dataset
  
file_path: OpenPrompt/openprompt/data_utils/data_sampler.py
imports: from collections import defaultdict, namedtuple
  from typing import *
  import numpy
  from torch.utils.data import Dataset
  from torch.utils.data.dataset import Subset
  from openprompt.utils.logging import logger
  from typing import Union
label_desc: Use image node_id 2 for calling the FewShotSampler obj's underlying member method code with example usage: obj.__call__(train_dataset, valid_dataset, seed) and returns: train_dataset,  valid_dataset, self, self