code: def validate_tt_matrix_rank(tensorized_shape, rank="same"):
      """Returns the rank of a TT-Matrix Decomposition
  
      Parameters
      ----------
      tensor_shape : tupe
          shape of the tensorized matrix to decompose
      rank : {'same', float, tuple, int}, default is same
          way to determine the rank, by default 'same'
          if 'same': rank is computed to keep the number of parameters (at most) the same
          if float, computes a rank so as to keep rank percent of the original number of parameters
          if int or tuple, just returns rank
      constant_rank : bool, default is False
          * if True, the *same* rank will be chosen for each modes
          * if False (default), the rank of each mode will be proportional to the corresponding tensor_shape
  
          *used only if rank == 'same' or 0 < rank <= 1*
  
      rounding = {'round', 'floor', 'ceil'}
  
      Returns
      -------
      rank : int tuple
          rank of the decomposition
      """
  
      n_dim = len(tensorized_shape) // 2
  
      if n_dim * 2 != len(tensorized_shape):
          msg = (
              f"The order of the give tensorized shape is not a multiple of 2."
              "However, there should be as many dimensions for the left side (number of rows)"
              " as of the right side (number of columns). "
              " For instance, to convert a matrix of size (8, 9) to the TT-format, "
              " it can be tensorized to (2, 4, 3, 3) but NOT to (2, 2, 2, 3, 3)."
          )
          raise ValueError(msg)
  
      left_shape = tensorized_shape[:n_dim]
      right_shape = tensorized_shape[n_dim:]
  
      full_shape = tuple(i * o for i, o in zip(left_shape, right_shape))
      return tl.tt_tensor.validate_tt_rank(full_shape, rank)
  
imports: import tensorly
  from .tenalg import _tt_matrix_to_tensor
  from ._factorized_tensor import FactorizedTensor
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: validate_tt_matrix_rank(tensorized_shape, rank) and returns: tl