class_docstr: Implementation of hyperopt.Trials supporting
  distributed execution using Apache Spark clusters.
  This requires fmin to be run on a Spark cluster.
  
  Plugging SparkTrials into hyperopt.fmin() allows hyperopt
  to send model training and evaluation tasks to Spark workers,
  parallelizing hyperparameter search.
  Each trial (set of hyperparameter values) is handled within
  a single Spark task; i.e., each model will be fit and evaluated
  on a single worker machine.  Trials are run asynchronously.
  
  See hyperopt.Trials docs for general information about Trials.
  
  The fields we store in our trial docs match the base Trials class.  The fields include:
   - 'tid': trial ID
   - 'state': JOB_STATE_DONE, JOB_STATE_ERROR, etc.
   - 'result': evaluation result for completed trial run
   - 'refresh_time': timestamp for last status update
   - 'misc': includes:
      - 'error': (error type, error message)
   - 'book_time': timestamp for trial run start
docstr: Given the requested parallelism, return the max parallelism SparkTrials will actually use.
  See the docstring for `parallelism` in the constructor for expected behavior.
docstr_tok: ["Given","the","requested","parallelism",",","return","the","max","parallelism","SparkTrials","will","actually","use",".","See","the","docstring","for","`","parallelism","`","in","the","constructor","for","expected","behavior","."]
code: def _decide_parallelism(
      requested_parallelism, spark_default_parallelism
  ):
      """
      Given the requested parallelism, return the max parallelism SparkTrials will actually use.
      See the docstring for `parallelism` in the constructor for expected behavior.
      """
      if requested_parallelism is None or requested_parallelism <= 0:
          parallelism = max(spark_default_parallelism, 1)
          logger.warning(
              "Because the requested parallelism was None or a non-positive value, "
              "parallelism will be set to ({d}), which is Spark's default parallelism ({s}), "
              "or 1, whichever is greater. "
              "We recommend setting parallelism explicitly to a positive value because "
              "the total of Spark task slots is subject to cluster sizing.".format(
                  d=parallelism, s=spark_default_parallelism
              )
          )
      else:
          parallelism = requested_parallelism
  
      if parallelism > SparkTrials.MAX_CONCURRENT_JOBS_ALLOWED:
          logger.warning(
              "Parallelism ({p}) is capped at SparkTrials.MAX_CONCURRENT_JOBS_ALLOWED ({c}).".format(
                  p=parallelism,
                  c=SparkTrials.MAX_CONCURRENT_JOBS_ALLOWED,
              )
          )
          parallelism = SparkTrials.MAX_CONCURRENT_JOBS_ALLOWED
      return parallelism
  
imports: import copy
  import os
  import threading
  import time
  import timeit
  import traceback
  from hyperopt import base, fmin, Trials
  from hyperopt.base import validate_timeout, validate_loss_threshold, STATUS_OK
  from hyperopt.utils import coarse_utcnow, _get_logger, _get_random_id
label_desc: Use image node_id 3 for calling the SparkTrials obj's underlying member method code with example usage: obj._decide_parallelism(requested_parallelism, spark_default_parallelism) and returns: parallelism