class_docstr: Perform cross validation or nested cross validation.
  
  For performing cross validation or nested cross validation, we really want to combine all the
  instances from all the sets or just some of the sets, then create a different data silo
  instance for each fold or nested fold.
  Calling DataSiloForCrossVal.make() creates a list of DataSiloForCrossVal instances - one for each fold.
class_docstr_tok: ["Perform","cross","validation","or","nested","cross","validation",".","For","performing","cross","validation","or","nested","cross","validation",",","we","really","want","to","combine","all","the","instances","from","all","the","sets","or","just","some","of","the","sets",",","then","create","a","different","data","silo","instance","for","each","fold","or","nested","fold",".","Calling","DataSiloForCrossVal.make","(",")","creates","a","list","of","DataSiloForCrossVal","instances","-","one","for","each","fold","."]
docstr: Create number of folds data-silo-like objects which can be used for training from the
  original data silo passed on.
  
  :param datasilo: the data silo that contains the original data
  :type datasilo: DataSilo
  :param sets: which sets to use to create the xval folds (strings)
  :type sets: list
  :param n_splits: number of folds to create
  :type n_splits: int
  :param shuffle: shuffle each class' samples before splitting
  :type shuffle: bool
  :param random_state: random state for shuffling
  :type random_state: int
  :param stratification: If class stratification should be done.
      It is never done with question answering.
  :type stratification: bool
  :param n_neg_answers_per_question: number of negative answers per question to include for training
  :type n_neg_answers_per_question: int
  :param n_inner_splits: Number of inner splits of a nested cross validation.
      Default is ``None`` which means to do a normal (not nested) cross validation.
      If at least 2 is given a nested cross validation is done. In that case the ``n_splits``
      parameter is the number of outer splits.
      The outer cross validation splits the data into a test set and a rest set.
      The inner cross validation splits the rest data into a train set and a dev set.
      The advantage of a nested cross validation is that it is doing the inner split
      not just by random but in a more systematic way. When doing model evaluation
      this also reduces the variance. This is because you train on more different
      iterations with more different data constellations.
  :type n_inner_splits: int
docstr_tok: ["Create","number","of","folds","data-silo-like","objects","which","can","be","used","for","training","from","the","original","data","silo","passed","on",".",":","param","datasilo",":","the","data","silo","that","contains","the","original","data",":","type","datasilo",":","DataSilo",":","param","sets",":","which","sets","to","use","to","create","the","xval","folds","(","strings",")",":","type","sets",":","list",":","param","n_splits",":","number","of","folds","to","create",":","type","n_splits",":","int",":","param","shuffle",":","shuffle","each","class","'","samples","before","splitting",":","type","shuffle",":","bool",":","param","random_state",":","random","state","for","shuffling",":","type","random_state",":","int",":","param","stratification",":","If","class","stratification","should","be","done",".","It","is","never","done","with","question","answering",".",":","type","stratification",":","bool",":","param","n_neg_answers_per_question",":","number","of","negative","answers","per","question","to","include","for","training",":","type","n_neg_answers_per_question",":","int",":","param","n_inner_splits",":","Number","of","inner","splits","of","a","nested","cross","validation",".","Default","is","``","None","``","which","means","to","do","a","normal","(","not","nested",")","cross","validation",".","If","at","least","2","is","given","a","nested","cross","validation","is","done",".","In","that","case","the","``","n_splits","``","parameter","is","the","number","of","outer","splits",".","The","outer","cross","validation","splits","the","data","into","a","test","set","and","a","rest","set",".","The","inner","cross","validation","splits","the","rest","data","into","a","train","set","and","a","dev","set",".","The","advantage","of","a","nested","cross","validation","is","that","it","is","doing","the","inner","split","not","just","by","random","but","in","a","more","systematic","way",".","When","doing","model","evaluation","this","also","reduces","the","variance",".","This","is","because","you","train","on","more","different","iterations","with","more","different","data","constellations",".",":","type","n_inner_splits",":","int"]
code: def make(
      cls,
      datasilo,
      sets=["train", "dev", "test"],
      n_splits=5,
      shuffle=True,
      random_state=None,
      stratification=True,
      n_neg_answers_per_question=1,
      n_inner_splits=None,
  ):
      """
      Create number of folds data-silo-like objects which can be used for training from the
      original data silo passed on.
  
      :param datasilo: the data silo that contains the original data
      :type datasilo: DataSilo
      :param sets: which sets to use to create the xval folds (strings)
      :type sets: list
      :param n_splits: number of folds to create
      :type n_splits: int
      :param shuffle: shuffle each class' samples before splitting
      :type shuffle: bool
      :param random_state: random state for shuffling
      :type random_state: int
      :param stratification: If class stratification should be done.
          It is never done with question answering.
      :type stratification: bool
      :param n_neg_answers_per_question: number of negative answers per question to include for training
      :type n_neg_answers_per_question: int
      :param n_inner_splits: Number of inner splits of a nested cross validation.
          Default is ``None`` which means to do a normal (not nested) cross validation.
          If at least 2 is given a nested cross validation is done. In that case the ``n_splits``
          parameter is the number of outer splits.
          The outer cross validation splits the data into a test set and a rest set.
          The inner cross validation splits the rest data into a train set and a dev set.
          The advantage of a nested cross validation is that it is doing the inner split
          not just by random but in a more systematic way. When doing model evaluation
          this also reduces the variance. This is because you train on more different
          iterations with more different data constellations.
      :type n_inner_splits: int
      """
      # check n_inner_splits param
      if (n_inner_splits is not None) and (not n_inner_splits >= 2):
          raise ValueError("'n_inner_splits' must be at least 2!")
  
      if (
          "question_answering" in datasilo.processor.tasks
          and n_inner_splits is None
      ):
          return cls._make_question_answering(
              datasilo,
              sets,
              n_splits,
              shuffle,
              random_state,
              n_neg_answers_per_question,
          )
      elif (
          "question_answering" in datasilo.processor.tasks
          and n_inner_splits is not None
      ):
          raise NotImplementedError()
      elif n_inner_splits is None:
          return cls._make(
              datasilo,
              sets,
              n_splits,
              shuffle,
              random_state,
              stratification,
          )
      elif n_inner_splits is not None:
          return cls._make_nested(
              datasilo,
              sets,
              n_splits,
              shuffle,
              random_state,
              stratification,
              n_inner_splits,
          )
      else:
          raise RuntimeError(
              "Cross validation can not be done under these conditions!"
          )
  
imports: import copy
  import logging
  import torch.multiprocessing
  from contextlib import ExitStack
  from functools import partial
  import random
  from pathlib import Path
  from itertools import chain, groupby
  import numpy
  from sklearn.utils.class_weight import compute_class_weight
  from torch.utils.data import Dataset, Subset, IterableDataset
  from torch.utils.data.distributed import DistributedSampler
  from torch.utils.data.sampler import RandomSampler, SequentialSampler
  import torch
  from sklearn.model_selection import StratifiedKFold, KFold, ShuffleSplit, StratifiedShuffleSplit
  from tqdm import tqdm
  from farm.data_handler.dataloader import NamedDataLoader
  from farm.data_handler.processor import Processor, BertStyleLMProcessor
  from farm.data_handler.utils import grouper
  from farm.data_handler.dataset import ConcatTensorDataset
  from farm.modeling.tokenization import EmbeddingTokenizer
  from farm.utils import MLFlowLogger
  from farm.utils import log_ascii_workers, calc_chunksize
  from farm.utils import get_dict_checksum
  from farm.visual.ascii.images import TRACTOR_SMALL
label_desc: Use image node_id 3 for calling the DataSiloForCrossVal obj's underlying member method code with example usage: obj.make(cls, datasilo, sets, n_splits, shuffle, random_state, stratification, n_neg_answers_per_question, n_inner_splits) and returns: cls, cls, cls