code: def random_tt(shape, rank, full=False, random_state=None, **context):
      """Generates a random TT/MPS tensor
  
      Parameters
      ----------
      shape : tuple
          shape of the tensor to generate
      rank : int
          rank of the TT decomposition
          must verify rank[0] == rank[-1] ==1 (boundary conditions)
          and len(rank) == len(shape)+1
      full : bool, optional, default is False
          if True, a full tensor is returned
          otherwise, the decomposed tensor is returned
      random_state : `np.random.RandomState`
      context : dict
          context in which to create the tensor
  
      Returns
      -------
      TT_tensor : ND-array or 3D-array list
          * ND-array : full tensor if `full` is True
          * 3D-array list : list of factors otherwise
      """
      n_dim = len(shape)
  
      rank = validate_tt_rank(shape, rank)
  
      # Make sure it's not a tuple but a list
      rank = list(rank)
  
      # Initialization
      if rank[0] != 1:
          message = "Provided rank[0] == {} but boundaring conditions dictatate rank[0] == rank[-1] == 1.".format(
              rank[0]
          )
          raise ValueError(message)
      if rank[-1] != 1:
          message = "Provided rank[-1] == {} but boundaring conditions dictatate rank[0] == rank[-1] == 1.".format(
              rank[-1]
          )
          raise ValueError(message)
  
      rns = T.check_random_state(random_state)
      factors = [
          T.tensor(
              rns.random_sample((rank[i], s, rank[i + 1])), **context
          )
          for i, s in enumerate(shape)
      ]
  
      if full:
          return tt_to_tensor(factors)
      else:
          return TTTensor(factors)
  
file_path: tensorly/tensorly/random/base.py
imports: import numpy
  from ..cp_tensor import cp_to_tensor, CPTensor, cp_normalize, validate_cp_rank
  from ..tucker_tensor import tucker_to_tensor, TuckerTensor, validate_tucker_rank
  from ..tt_tensor import tt_to_tensor, TTTensor, validate_tt_rank
  from ..tt_matrix import tt_matrix_to_tensor, TTMatrix, validate_tt_matrix_rank
  from ..tr_tensor import TRTensor, tr_to_tensor, validate_tr_rank
  from ..parafac2_tensor import parafac2_to_tensor, Parafac2Tensor, parafac2_normalise
  from ..None import backend
  import warnings
label_desc: Use image node_id 5 for calling a global function with example usage: random_tt(shape, rank, full, random_state) and returns: tt_to_tensor, TTTensor