code: def check_subsample_index(n_samples, partitions, folds, raise_):
      """Check input validity of the SubsampleIndexer."""
      if not isinstance(partitions, Integral):
          raise ValueError(
              "'partitions' must be an integer. "
              "type(%s) was passed." % type(partitions)
          )
  
      if not partitions > 0:
          raise ValueError(
              "'partitions' must be a positive integer. "
              "{} was passed.".format(partitions)
          )
  
      if not isinstance(folds, Integral):
          raise ValueError(
              "'folds' must be an integer. "
              "type(%s) was passed." % type(folds)
          )
  
      if folds == 1:
          if raise_ or partitions > 1:
              raise ValueError(
                  "Need at least 2 folds for splitting partitions. "
                  "Got %i." % folds
              )
          else:
              if partitions == 1 and folds == 1:
                  warnings.warn(
                      "'folds' is 1, will return full index as "
                      "both training set and test set."
                  )
      s = partitions * folds
      if s > n_samples:
          raise ValueError(
              "Number of total splits %i is greater than the "
              "number of samples: %i." % (s, n_samples)
          )
  
imports: from __future__ import division
  from numbers import Integral
  import warnings
label_desc: Use image node_id 3 for calling a global function with example usage: check_subsample_index(n_samples, partitions, folds, raise_) without return types