code: def least_squares(Cui, X, Y, regularization, num_threads=0):
      """For each user in Cui, calculate factors Xu for them
      using least squares on Y.
  
      Note: this is at least 10 times slower than the cython version included
      here.
      """
      users, n_factors = X.shape
      YtY = Y.T.dot(Y)
  
      for u in range(users):
          X[u] = user_factor(Y, YtY, Cui, u, regularization, n_factors)
  
imports: import functools
  import heapq
  import logging
  import time
  import numpy
  import scipy
  import scipy.sparse
  from tqdm.auto import tqdm
  from ..utils import check_blas_config, check_csr, check_random_state, nonzeros
  from .None import _als
  from .matrix_factorization_base import MatrixFactorizationBase
label_desc: Use image node_id 1 for calling a global function with example usage: least_squares(Cui, X, Y, regularization, num_threads) without return types