code: def fold_request(cv_opts):
      """Computes k-fold cross-validation folds.
      Emulates :func:`optunity.cross_validated`."""
      try:
          num_instances = cv_opts["num_instances"]
      except (KeyError, ValueError):
          msg = {
              "error_msg": "number of instances num_instances must be set."
          }
          comm.send(comm.json_encode(msg))
          print(startup_msg, file=sys.stderr)
          exit(1)
  
      num_folds = cv_opts.get("num_folds", 10)
      strata = cv_opts.get("strata", None)
      clusters = cv_opts.get("clusters", None)
      num_iter = cv_opts.get("num_iter", 1)
  
      folds = [
          optunity.generate_folds(
              num_instances,
              num_folds=num_folds,
              strata=strata,
              clusters=clusters,
          )
          for _ in range(num_iter)
      ]
  
      msg = {"folds": folds}
      comm.send(comm.json_encode(msg))
      exit(0)
  
file_path: optunity/wrappers/R/inst/optunity/standalone.py
imports: from __future__ import print_function
  import sys
  import keyword
  from .None import communication
  from .None import functions
  import optunity
label_desc: Use image node_id 3 for calling a global function with example usage: fold_request(cv_opts) without return types