code: def compute_svd(X, n_components, n_iter, random_state, engine) -> SVD:
      """Computes an SVD with k components."""
  
      # TODO: support sample weights
  
      # Compute the SVD
      if engine == "fbpca":
          if FBPCA_INSTALLED:
              U, s, V = fbpca.pca(X, k=n_components, n_iter=n_iter)
          else:
              raise ValueError(
                  "fbpca is not installed; please install it if you want to use it"
              )
      elif engine == "scipy":
          U, s, V = scipy.linalg.svd(X)
          U = U[:, :n_components]
          s = s[:n_components]
          V = V[:n_components, :]
      elif engine == "sklearn":
          U, s, V = extmath.randomized_svd(
              X,
              n_components=n_components,
              n_iter=n_iter,
              random_state=random_state,
          )
      else:
          raise ValueError(
              "engine has to be one of ('fbpca', 'scipy', 'sklearn')"
          )
  
      # U, V = extmath.svd_flip(U, V)
  
      return SVD(U, s, V)
  
imports: from __future__ import annotations
  import dataclasses
  import numpy
  import scipy
  from sklearn.utils import extmath
label_desc: Use image node_id 1 for calling a global function with example usage: compute_svd(X, n_components, n_iter, random_state, engine) and returns: SVD