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","."]
code: def _make_nested(
      datasilo,
      sets=["train", "dev", "test"],
      n_splits=5,
      shuffle=True,
      random_state=None,
      stratification=True,
      n_inner_splits=5,
  ):
      setstoconcat = [datasilo.data[setname] for setname in sets]
      ds_all = ConcatTensorDataset(setstoconcat)
      idxs = list(range(len(ds_all)))
  
      silos = []
  
      # outer cross validation where we split all data to test and rest
      if stratification:
          # get all the labels for stratification
          ytensors = [t[3][0] for t in ds_all]
          y = torch.stack(ytensors)
          outer_cv = StratifiedKFold(
              n_splits=n_splits,
              shuffle=shuffle,
              random_state=random_state,
          )
          outer_split = outer_cv.split(idxs, y)
      else:
          outer_cv = KFold(
              n_splits=n_splits,
              shuffle=shuffle,
              random_state=random_state,
          )
          outer_split = outer_cv.split(idxs)
      for idxs_rest, idxs_test in outer_split:
          # inner cross validation where we split rest data into train and dev
          if stratification:
              y_rest = y[idxs_rest]
              inner_cv = StratifiedKFold(
                  n_splits=n_inner_splits,
                  shuffle=shuffle,
                  random_state=random_state,
              )
              inner_split = inner_cv.split(idxs_rest, y_rest)
          else:
              inner_cv = KFold(
                  n_splits=n_inner_splits,
                  shuffle=shuffle,
                  random_state=random_state,
              )
              inner_split = inner_cv.split(idxs_rest)
          for idxs_train_idxs, idxs_dev_idxs in inner_split:
              # split idxs_rest with indexes from inner cross validation
              idxs_train = idxs_rest[idxs_train_idxs]
              idxs_dev = idxs_rest[idxs_dev_idxs]
  
              ds_train = Subset(ds_all, idxs_train)
              ds_dev = Subset(ds_all, idxs_dev)
              ds_test = Subset(ds_all, idxs_test)
              silos.append(
                  DataSiloForCrossVal(
                      datasilo, ds_train, ds_dev, ds_test
                  )
              )
      return silos
  
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 7 for calling the DataSiloForCrossVal obj's underlying member method code with example usage: obj._make_nested(datasilo, sets, n_splits, shuffle, random_state, stratification, n_inner_splits) and returns: silos