code: def test_validate_tucker_tensor():
      rng = tl.check_random_state(1234)
      true_shape = (3, 4, 5)
      true_rank = (3, 2, 4)
      core, factors = random_tucker(
          true_shape, rank=true_rank, random_state=rng
      )
  
      # Check shape and rank returned
      shape, rank = _validate_tucker_tensor((core, factors))
      assert_equal(
          shape,
          true_shape,
          err_msg=f"Returned incorrect shape (got {shape}, expected {true_shape})",
      )
      assert_equal(
          rank,
          true_rank,
          err_msg=f"Returned incorrect rank (got {rank}, expected {true_rank})",
      )
  
      # One of the factors has the wrong rank
      factors[0], copy = (
          tl.tensor(rng.random_sample((4, 4))),
          factors[0],
      )
      with assert_raises(ValueError):
          _validate_tucker_tensor((core, factors))
  
      # Not enough factors to match core
      factors[0] = copy
      with assert_raises(ValueError):
          _validate_tucker_tensor((core, factors[1:]))
  
      # Not enough factors
      with assert_raises(ValueError):
          _validate_tucker_tensor((core, factors[:1]))
  
file_path: tensorly/tensorly/tests/test_tucker_tensor.py
imports: import numpy
  from ..None import backend
  from ..base import unfold, tensor_to_vec
  from ..tucker_tensor import tucker_to_tensor, tucker_to_unfolded, tucker_to_vec, _validate_tucker_tensor, tucker_mode_dot, tucker_normalize, _tucker_n_param, validate_tucker_rank
  from ..tenalg import kronecker, mode_dot
  from ..testing import assert_array_equal, assert_array_almost_equal, assert_equal, assert_raises, assert_
  from ..random import random_tucker
label_desc: Use image node_id 1 for calling a global function with example usage: test_validate_tucker_tensor() without return types