code: def random_tt_matrix(
      shape, rank, full=False, random_state=None, **context
  ):
      """Generates a random tensor in TT-Matrix format
  
      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) // 2
      left_shape = shape[:n_dim]
      right_shape = shape[n_dim:]
  
      rank = validate_tt_matrix_rank(shape, rank)
  
      factors = []
      for i in range(n_dim):
          factors.append(
              random_tensor(
                  (rank[i], left_shape[i], right_shape[i], rank[i + 1]),
                  random_state=random_state,
                  **context,
              )
          )
  
      if full:
          return tt_matrix_to_tensor(factors)
      else:
          return TTMatrix(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 6 for calling a global function with example usage: random_tt_matrix(shape, rank, full, random_state) and returns: tt_matrix_to_tensor, TTMatrix