code: def _update_dict(
      dictionary,
      Y,
      code,
      verbose=False,
      return_r2=False,
      random_state=None,
  ):
      """Update the dense dictionary factor in place.
  
      Parameters
      ----------
      dictionary: array of shape (n_features, n_components)
          Value of the dictionary at the previous iteration.
  
      Y: array of shape (n_features, n_samples)
          Data matrix.
  
      code: array of shape (n_components, n_samples)
          Sparse coding of the data against which to optimize the dictionary.
  
      verbose:
          Degree of output the procedure will print.
  
      return_r2: bool
          Whether to compute and return the residual sum of squares corresponding
          to the computed solution.
  
      random_state: int or RandomState
          Pseudo number generator state used for random sampling.
  
      Returns
      -------
      dictionary: array of shape (n_features, n_components)
          Updated dictionary.
  
      """
      n_components = len(code)
      n_samples = Y.shape[0]
      random_state = check_random_state(random_state)
      # Residuals, computed 'in-place' for efficiency
      R = -np.dot(dictionary, code)
      R += Y
      R = np.asfortranarray(R)
      (ger,) = linalg.get_blas_funcs(("ger",), (dictionary, code))
      for k in range(n_components):
          # R <- 1.0 * U_k * V_k^T + R
          R = ger(
              1.0, dictionary[:, k], code[k, :], a=R, overwrite_a=True
          )
          dictionary[:, k] = np.dot(R, code[k, :].T)
          # Scale k'th atom
          atom_norm_square = np.dot(dictionary[:, k], dictionary[:, k])
          if atom_norm_square < 1e-20:
              if verbose == 1:
                  sys.stdout.write("+")
                  sys.stdout.flush()
              elif verbose:
                  print("Adding new random atom")
              dictionary[:, k] = random_state.randn(n_samples)
              # Setting corresponding coefs to 0
              code[k, :] = 0.0
              dictionary[:, k] /= sqrt(
                  np.dot(dictionary[:, k], dictionary[:, k])
              )
          else:
              dictionary[:, k] /= sqrt(atom_norm_square)
              # R <- -1.0 * U_k * V_k^T + R
              R = ger(
                  -1.0,
                  dictionary[:, k],
                  code[k, :],
                  a=R,
                  overwrite_a=True,
              )
      if return_r2:
          R **= 2
          # R is fortran-ordered. For numpy version < 1.6, sum does not
          # follow the quick striding first, and is thus inefficient on
          # fortran ordered data. We take a flat view of the data with no
          # striding
          R = as_strided(
              R, shape=(R.size,), strides=(R.dtype.itemsize,)
          )
          R = np.sum(R)
          return dictionary, R
      return dictionary
  
imports: from __future__ import print_function
  import time
  import sys
  import itertools
  from math import sqrt, ceil
  import numpy
  from scipy import linalg
  from numpy.lib.stride_tricks import as_strided
  from ..base import BaseEstimator, TransformerMixin
  from ..externals.joblib import Parallel, delayed, cpu_count
  from ..externals.six.moves import zip
  from ..utils import check_array, check_random_state, gen_even_slices, gen_batches, _get_n_jobs
  from ..utils.extmath import randomized_svd, row_norms
  from ..utils.validation import check_is_fitted
  from ..linear_model import Lasso, orthogonal_mp_gram, LassoLars, Lars
label_desc: Use image node_id 3 for calling a global function with example usage: _update_dict(dictionary, Y, code, verbose, return_r2, random_state) and returns: dictionary, dictionary,  R