code: def tensor_train(
      input_tensor, rank, svd="truncated_svd", verbose=False
  ):
      """TT decomposition via recursive SVD
  
          Decomposes `input_tensor` into a sequence of order-3 tensors (factors)
          -- also known as Tensor-Train decomposition [1]_.
  
      Parameters
      ----------
      input_tensor : tensorly.tensor
      rank : {int, int list}
              maximum allowable TT rank of the factors
              if int, then this is the same for all the factors
              if int list, then rank[k] is the rank of the kth factor
      svd : str, default is 'truncated_svd'
          function to use to compute the SVD, acceptable values in tensorly.SVD_FUNS
      verbose : boolean, optional
              level of verbosity
  
      Returns
      -------
      factors : TT factors
                order-3 tensors of the TT decomposition
  
      References
      ----------
      .. [1] Ivan V. Oseledets. "Tensor-train decomposition", SIAM J. Scientific Computing, 33(5):2295–2317, 2011.
      """
      rank = validate_tt_rank(tl.shape(input_tensor), rank=rank)
      tensor_size = input_tensor.shape
      n_dim = len(tensor_size)
  
      unfolding = input_tensor
      factors = [None] * n_dim
  
      # Getting the TT factors up to n_dim - 1
      for k in range(n_dim - 1):
          # Reshape the unfolding matrix of the remaining factors
          n_row = int(rank[k] * tensor_size[k])
          unfolding = tl.reshape(unfolding, (n_row, -1))
  
          # SVD of unfolding matrix
          (n_row, n_column) = unfolding.shape
          current_rank = min(n_row, n_column, rank[k + 1])
          U, S, V = svd_interface(
              unfolding, n_eigenvecs=current_rank, method=svd
          )
  
          rank[k + 1] = current_rank
  
          # Get kth TT factor
          factors[k] = tl.reshape(
              U, (rank[k], tensor_size[k], rank[k + 1])
          )
  
          if verbose is True:
              print(
                  "TT factor "
                  + str(k)
                  + " computed with shape "
                  + str(factors[k].shape)
              )
  
          # Get new unfolding matrix for the remaining factors
          unfolding = tl.reshape(S, (-1, 1)) * V
  
      # Getting the last factor
      (prev_rank, last_dim) = unfolding.shape
      factors[-1] = tl.reshape(unfolding, (prev_rank, last_dim, 1))
  
      if verbose is True:
          print(
              "TT factor "
              + str(n_dim - 1)
              + " computed with shape "
              + str(factors[n_dim - 1].shape)
          )
  
      return TTTensor(factors)
  
file_path: tensorly/tensorly/decomposition/_tt.py
imports: import tensorly
  from ._base_decomposition import DecompositionMixin
  from ..tt_tensor import validate_tt_rank, TTTensor
  from ..tt_matrix import validate_tt_matrix_rank, TTMatrix
  from ..tenalg.svd import svd_interface
label_desc: Use image node_id 1 for calling a global function with example usage: tensor_train(input_tensor, rank, svd, verbose) and returns: TTTensor