code: def _set_path(job, path, threading):
      """Build path as a cache or list depending on whether using threading"""
      if path:
          if not isinstance(path, str) and not threading:
              raise ValueError(
                  "Path must be a str with backend=multiprocessing."
                  " Got %r" % path.__class__
              )
          elif not isinstance(path, (str, dict)):
              raise ValueError(
                  "Invalid path format. Should be one of "
                  "str, dict. Got %r" % path.__class__
              )
          job.dir = path
          return job
  
      if threading:
          # No need to pickle
          job.dir = dict()
          return job
  
      # Else, need a directory
      path = config.get_tmpdir()
      try:
          job.tmp = tempfile.TemporaryDirectory(
              prefix=config.get_prefix(), dir=path
          )
          job.dir = job.tmp.name
      except AttributeError:
          # Fails on python 2
          job.dir = tempfile.mkdtemp(
              prefix=config.get_prefix(), dir=path
          )
      return job
  
imports: from __future__ import with_statement, division
  import gc
  import os
  import shutil
  import subprocess
  import tempfile
  import warnings
  from abc import ABCMeta, abstractmethod
  import numpy
  from scipy.sparse import issparse, hstack
  from ..None import config
  from ..externals.joblib import Parallel, dump, load
  from ..utils import check_initialized
  from ..utils.exceptions import ParallelProcessingError, ParallelProcessingWarning
  from ..externals.sklearn.validation import check_random_state
label_desc: Use image node_id 5 for calling a global function with example usage: _set_path(job, path, threading) and returns: job, job, job