code: def initialize_tucker(
      tensor,
      rank,
      modes,
      random_state,
      init="svd",
      svd="truncated_svd",
      non_negative=False,
      mask=None,
      svd_mask_repeats=5,
  ):
      """
      Initialize core and factors used in `tucker`.
      The type of initialization is set using `init`. If `init == 'random'` then
      initialize factor matrices using `random_state`. If `init == 'svd'` then
      initialize the `m`th factor matrix using the `rank` left singular vectors
      of the `m`th unfolding of the input tensor.
  
      Parameters
      ----------
      tensor : ndarray
      rank : int
             number of components
      modes : int list
      random_state : {None, int, np.random.RandomState}
      init : {'svd', 'random', cptensor}, optional
      svd : str, default is 'truncated_svd'
            function to use to compute the SVD, acceptable values in tensorly.SVD_FUNS
      non_negative : bool, default is False
          if True, non-negative factors are returned
  
      Returns
      -------
      core    : ndarray
                initialized core tensor
      factors : list of factors
      """
      # Initialisation
      if init == "svd":
          factors = []
          for index, mode in enumerate(modes):
              mask_unfold = None if mask is None else unfold(mask, mode)
              U, _, _ = svd_interface(
                  unfold(tensor, mode),
                  n_eigenvecs=rank[index],
                  method=svd,
                  non_negative=non_negative,
                  mask=mask_unfold,
                  n_iter_mask_imputation=svd_mask_repeats,
                  random_state=random_state,
              )
  
              factors.append(U)
          # The initial core approximation is needed here for the masking step
          core = multi_mode_dot(
              tensor, factors, modes=modes, transpose=True
          )
  
      elif init == "random":
          rng = tl.check_random_state(random_state)
          core = tl.tensor(
              rng.random_sample(
                  [rank[index] for index in range(len(modes))]
              )
              + 0.01,
              **tl.context(tensor),
          )  # Check this
          factors = [
              tl.tensor(
                  rng.random_sample((tensor.shape[mode], rank[index])),
                  **tl.context(tensor),
              )
              for index, mode in enumerate(modes)
          ]
  
      else:
          (core, factors) = init
  
      if non_negative is True:
          factors = [tl.abs(f) for f in factors]
          core = tl.abs(core)
  
      return core, factors
  
imports: import tensorly
  from ._base_decomposition import DecompositionMixin
  from ..base import unfold
  from ..tenalg import multi_mode_dot, mode_dot
  from ..tucker_tensor import tucker_to_tensor, TuckerTensor, validate_tucker_rank, tucker_normalize
  from ..tenalg.proximal import hals_nnls, active_set_nnls, fista
  from math import sqrt
  import warnings
  from collections.abc import Iterable
  from ..tenalg.svd import svd_interface
label_desc: Use image node_id 1 for calling a global function with example usage: initialize_tucker(tensor, rank, modes, random_state, init, svd, non_negative, mask, svd_mask_repeats) and returns: core,  factors