code: def _multiplicative_update_w(
      X,
      W,
      H,
      beta_loss,
      l1_reg_W,
      l2_reg_W,
      gamma,
      H_sum=None,
      HHt=None,
      XHt=None,
      update_H=True,
  ):
      """Update W in Multiplicative Update NMF."""
      if beta_loss == 2:
          # Numerator
          if XHt is None:
              XHt = safe_sparse_dot(X, H.T)
          if update_H:
              # avoid a copy of XHt, which will be re-computed (update_H=True)
              numerator = XHt
          else:
              # preserve the XHt, which is not re-computed (update_H=False)
              numerator = XHt.copy()
  
          # Denominator
          if HHt is None:
              HHt = np.dot(H, H.T)
          denominator = np.dot(W, HHt)
  
      else:
          # Numerator
          # if X is sparse, compute WH only where X is non zero
          WH_safe_X = _special_sparse_dot(W, H, X)
          if sp.issparse(X):
              WH_safe_X_data = WH_safe_X.data
              X_data = X.data
          else:
              WH_safe_X_data = WH_safe_X
              X_data = X
              # copy used in the Denominator
              WH = WH_safe_X.copy()
              if beta_loss - 1.0 < 0:
                  WH[WH < EPSILON] = EPSILON
  
          # to avoid taking a negative power of zero
          if beta_loss - 2.0 < 0:
              WH_safe_X_data[WH_safe_X_data < EPSILON] = EPSILON
  
          if beta_loss == 1:
              np.divide(X_data, WH_safe_X_data, out=WH_safe_X_data)
          elif beta_loss == 0:
              # speeds up computation time
              # refer to /numpy/numpy/issues/9363
              WH_safe_X_data **= -1
              WH_safe_X_data **= 2
              # element-wise multiplication
              WH_safe_X_data *= X_data
          else:
              WH_safe_X_data **= beta_loss - 2
              # element-wise multiplication
              WH_safe_X_data *= X_data
  
          # here numerator = dot(X * (dot(W, H) ** (beta_loss - 2)), H.T)
          numerator = safe_sparse_dot(WH_safe_X, H.T)
  
          # Denominator
          if beta_loss == 1:
              if H_sum is None:
                  H_sum = np.sum(H, axis=1)  # shape(n_components, )
              denominator = H_sum[np.newaxis, :]
  
          else:
              # computation of WHHt = dot(dot(W, H) ** beta_loss - 1, H.T)
              if sp.issparse(X):
                  # memory efficient computation
                  # (compute row by row, avoiding the dense matrix WH)
                  WHHt = np.empty(W.shape)
                  for i in range(X.shape[0]):
                      WHi = np.dot(W[i, :], H)
                      if beta_loss - 1 < 0:
                          WHi[WHi < EPSILON] = EPSILON
                      WHi **= beta_loss - 1
                      WHHt[i, :] = np.dot(WHi, H.T)
              else:
                  WH **= beta_loss - 1
                  WHHt = np.dot(WH, H.T)
              denominator = WHHt
  
      # Add L1 and L2 regularization
      if l1_reg_W > 0:
          denominator += l1_reg_W
      if l2_reg_W > 0:
          denominator = denominator + l2_reg_W * W
      denominator[denominator == 0] = EPSILON
  
      numerator /= denominator
      delta_W = numerator
  
      # gamma is in ]0, 1]
      if gamma != 1:
          delta_W **= gamma
  
      W *= delta_W
  
      return W, H_sum, HHt, XHt
  
imports: import itertools
  import time
  import warnings
  from abc import ABC
  from math import sqrt
  from numbers import Integral, Real
  import numpy
  import scipy.sparse
  from scipy import linalg
  from .._config import config_context
  from ..base import BaseEstimator, ClassNamePrefixFeaturesOutMixin, TransformerMixin, _fit_context
  from ..exceptions import ConvergenceWarning
  from ..utils import check_array, check_random_state, gen_batches, metadata_routing
  from ..utils._param_validation import Hidden, Interval, StrOptions, validate_params
  from ..utils.extmath import randomized_svd, safe_sparse_dot, squared_norm
  from ..utils.validation import check_is_fitted, check_non_negative
  from ._cdnmf_fast import _update_cdnmf_fast
label_desc: Use image node_id 10 for calling a global function with example usage: _multiplicative_update_w(X, W, H, beta_loss, l1_reg_W, l2_reg_W, gamma, H_sum, HHt, XHt, update_H) and returns: W,  H_sum,  HHt,  XHt