ValueError: buffer source array is read-only In DictionaryLearning using coordinate decent, numworkers = 15

### Describe the bug

I get "source array is read only" error in Dictionary Learning when I try to fit it to the Cifar10 Dataset. 

### Steps/Code to Reproduce

```python
from sklearn.decomposition import DictionaryLearning
from keras.datasets import cifar10

(x_train, y_train), (x_test, y_test) = cifar10.load_data() #or x_train = np.random((50000, 32,32,3))


dict_learner = DictionaryLearning(
    n_components= 56,
    random_state=0,
    n_jobs=15,
    fit_algorithm='cd',
    verbose= True,
    max_iter= 50
)
s_train = dict_learner.fit_transform(x_train.reshape(50000, 3072))
```

### Expected Results

The dictionary

### Actual Results

```pytb
 File "sklearn\linear_model\_cd_fast.pyx", line 568, in sklearn.linear_model._cd_fast.enet_coordinate_descent_gram
  File "stringsource", line 660, in View.MemoryView.memoryview_cwrapper
  File "stringsource", line 350, in View.MemoryView.memoryview.__cinit__
ValueError: buffer source array is read-only
"""

The above exception was the direct cause of the following exception:

ValueError                                Traceback (most recent call last)
Cell In [16], line 13
      4 #out = dict_learning_online(x_train[np.random.choice(a=50000, size=10000)].reshape(10000, 3072), n_components=3072)
      5 dict_learner = DictionaryLearning(
      6     n_components= 56,
      7     random_state=0,
   (...)
     11     max_iter= 50
     12 )
---> 13 s_train = dict_learner.fit_transform(x_train.reshape(50000, 3072))

File c:\Users\shafi\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\_set_output.py:142, in _wrap_method_output.<locals>.wrapped(self, X, *args, **kwargs)
    140 @wraps(f)
    141 def wrapped(self, X, *args, **kwargs):
--> 142     data_to_wrap = f(self, X, *args, **kwargs)
    143     if isinstance(data_to_wrap, tuple):
    144         # only wrap the first output for cross decomposition
    145         return (
    146             _wrap_data_with_container(method, data_to_wrap[0], X, self),
    147             *data_to_wrap[1:],
    148         )

File c:\Users\shafi\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\_set_output.py:142, in _wrap_method_output.<locals>.wrapped(self, X, *args, **kwargs)
    140 @wraps(f)
    141 def wrapped(self, X, *args, **kwargs):
--> 142     data_to_wrap = f(self, X, *args, **kwargs)
    143     if isinstance(data_to_wrap, tuple):
    144         # only wrap the first output for cross decomposition
    145         return (
    146             _wrap_data_with_container(method, data_to_wrap[0], X, self),
    147             *data_to_wrap[1:],
    148         )

File c:\Users\shafi\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\_set_output.py:142, in _wrap_method_output.<locals>.wrapped(self, X, *args, **kwargs)
    140 @wraps(f)
    141 def wrapped(self, X, *args, **kwargs):
--> 142     data_to_wrap = f(self, X, *args, **kwargs)
    143     if isinstance(data_to_wrap, tuple):
    144         # only wrap the first output for cross decomposition
    145         return (
    146             _wrap_data_with_container(method, data_to_wrap[0], X, self),
    147             *data_to_wrap[1:],
    148         )

File c:\Users\shafi\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\base.py:848, in TransformerMixin.fit_transform(self, X, y, **fit_params)
    844 # non-optimized default implementation; override when a better
    845 # method is possible for a given clustering algorithm
    846 if y is None:
    847     # fit method of arity 1 (unsupervised transformation)
--> 848     return self.fit(X, **fit_params).transform(X)
    849 else:
    850     # fit method of arity 2 (supervised transformation)
    851     return self.fit(X, y, **fit_params).transform(X)

File c:\Users\shafi\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\decomposition\_dict_learning.py:1719, in DictionaryLearning.fit(self, X, y)
   1716 else:
   1717     n_components = self.n_components
-> 1719 V, U, E, self.n_iter_ = dict_learning(
   1720     X,
   1721     n_components,
   1722     alpha=self.alpha,
   1723     tol=self.tol,
   1724     max_iter=self.max_iter,
   1725     method=self.fit_algorithm,
...
--> 389         raise self._exception
    390     else:
    391         return self._result

ValueError: buffer source array is read-only
```

### Versions

```shell
System:
    python: 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
executable: c:\Users\shafi\AppData\Local\Programs\Python\Python39\python.exe
   machine: Windows-10-10.0.19041-SP0

Python dependencies:
      sklearn: 1.2.0
          pip: 20.2.3
   setuptools: 49.2.1
        numpy: 1.23.4
        scipy: 1.8.0
       Cython: None
       pandas: 1.5.1
   matplotlib: 3.4.3
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\shafi\AppData\Roaming\Python\Python39\site-packages\numpy\.libs\libopenblas.WCDJNK7YVMPZQ2ME2ZZHJJRJ3JIKNDB7.gfortran-win_amd64.dll
        version: 0.3.13
threading_layer: pthreads
   architecture: Zen
    num_threads: 16

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\shafi\AppData\Local\Programs\Python\Python39\Lib\site-packages\scipy\.libs\libopenblas.XWYDX2IKJW2NMTWSFYNGFUWKQU3LYTCZ.gfortran-win_amd64.dll
        version: 0.3.17
threading_layer: pthreads
   architecture: Zen
    num_threads: 16

       user_api: openmp
   internal_api: openmp
         prefix: vcomp
       filepath: C:\Users\shafi\AppData\Local\Programs\Python\Python39\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None
    num_threads: 16
```

COMMENT:
I can reproduce with this simpler snippet (takes ~50s before the error happens):
```py
from sklearn.decomposition import DictionaryLearning
import numpy as np

rng = np.random.RandomState(0)
X_train = rng.randn(5000, 3072)

dict_learner = DictionaryLearning(
    n_components=56,
    random_state=0,
    n_jobs=2,
    fit_algorithm="cd",
    verbose=True,
    max_iter=50,
)

dict_learner.fit(X_train)
```

As the stack-trace below mentions, this is an issue for `fit_algorithm="cd"`.

I get the following stack-trace (scikit-learn 1.2.0):
```
joblib.externals.loky.process_executor._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/joblib/externals/loky/process_executor.py", line 428, in _process_worker
    r = call_item()
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/joblib/externals/loky/process_executor.py", line 275, in __call__
    return self.fn(*self.args, **self.kwargs)
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/joblib/_parallel_backends.py", line 620, in __call__
    return self.func(*args, **kwargs)
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/joblib/parallel.py", line 288, in __call__
    return [func(*args, **kwargs)
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/joblib/parallel.py", line 288, in <listcomp>
    return [func(*args, **kwargs)
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/sklearn/utils/fixes.py", line 117, in __call__
    return self.function(*args, **kwargs)
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/sklearn/decomposition/_dict_learning.py", line 179, in _sparse_encode
    clf.fit(dictionary.T, X.T, check_input=check_input)
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/sklearn/linear_model/_coordinate_descent.py", line 1007, in fit
    _, this_coef, this_dual_gap, this_iter = self.path(
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/sklearn/linear_model/_coordinate_descent.py", line 620, in enet_path
    model = cd_fast.enet_coordinate_descent_gram(
  File "sklearn/linear_model/_cd_fast.pyx", line 568, in sklearn.linear_model._cd_fast.enet_coordinate_descent_gram
  File "stringsource", line 660, in View.MemoryView.memoryview_cwrapper
  File "stringsource", line 350, in View.MemoryView.memoryview.__cinit__
ValueError: buffer source array is read-only
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/tmp/test.py", line 16, in <module>
    dict_learner.fit(X_train)
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/sklearn/decomposition/_dict_learning.py", line 1719, in fit
    V, U, E, self.n_iter_ = dict_learning(
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/sklearn/decomposition/_dict_learning.py", line 678, in dict_learning
    code = sparse_encode(
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/sklearn/decomposition/_dict_learning.py", line 391, in sparse_encode
    code_views = Parallel(n_jobs=n_jobs, verbose=verbose)(
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/joblib/parallel.py", line 1098, in __call__
    self.retrieve()
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/joblib/parallel.py", line 975, in retrieve
    self._output.extend(job.get(timeout=self.timeout))
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/site-packages/joblib/_parallel_backends.py", line 567, in wrap_future_result
    return future.result(timeout=timeout)
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/home/lesteve/miniconda3/envs/test/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
ValueError: buffer source array is read-only
```

Labels: Bug, module:decomposition