parameters: (backend, n_jobs=-1, **backend_params)
docstring: 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
docstring_summary: Change the default backend used by Parallel inside a with block.
docstring_tokens: Change the default backend used by Parallel inside a with block .
function: 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
function_tokens: def parallel_backend ( backend , n_jobs = - 1 , * * backend_params ) : 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