code: def parallel_backend(backend, n_jobs=-1, **backend_params):
      """Change the default backend used by Parallel inside a with block.
  
      If ``backend`` is a string it must match a previously registered
      implementation using the ``register_parallel_backend`` function.
  
      Alternatively backend can be passed directly as an instance.
  
      By default all available workers will be used (``n_jobs=-1``) unless the
      caller passes an explicit value for the ``n_jobs`` parameter.
  
      This is an alternative to passing a ``backend='backend_name'`` argument to
      the ``Parallel`` class constructor. It is particularly useful when calling
      into library code that uses joblib internally but does not expose the
      backend argument in its own API.
  
      >>> from operator import neg
      >>> with parallel_backend('threading'):
      ...     print(Parallel()(delayed(neg)(i + 1) for i in range(5)))
      ...
      [-1, -2, -3, -4, -5]
  
      Warning: this function is experimental and subject to change in a future
      version of joblib.
  
      .. versionadded:: 0.10
  
      """
      if isinstance(backend, _basestring):
          backend = BACKENDS[backend](**backend_params)
      old_backend_and_jobs = getattr(_backend, "backend_and_jobs", None)
      try:
          _backend.backend_and_jobs = (backend, n_jobs)
          # return the backend instance to make it easier to write tests
          yield backend, n_jobs
      finally:
          if old_backend_and_jobs is None:
              if (
                  getattr(_backend, "backend_and_jobs", None)
                  is not None
              ):
                  del _backend.backend_and_jobs
          else:
              _backend.backend_and_jobs = old_backend_and_jobs
  
imports: from __future__ import division
  import os
  import sys
  from math import sqrt
  import functools
  import time
  import threading
  import itertools
  from numbers import Integral
  from contextlib import contextmanager
  import warnings
  from ...config import get_start_method
  from ._multiprocessing_helpers import mp
  from .format_stack import format_outer_frames
  from .logger import Logger, short_format_time
  from .my_exceptions import TransportableException, _mk_exception
  from .disk import memstr_to_bytes
  from ._parallel_backends import FallbackToBackend, MultiprocessingBackend, ThreadingBackend, SequentialBackend
  from ._compat import _basestring
  from ._parallel_backends import AutoBatchingMixin
  from ._parallel_backends import ParallelBackendBase
label_desc: Use image node_id 2 for calling a global function with example usage: parallel_backend(backend, n_jobs) without return types