code: def test_tensor_train_cross_1():
      """Test for tensor-train"""
  
      ## Test 1
  
      # Create tensor with random elements
      d = 3
      n = 4
      tensor = np.arange(n**d, dtype=float).reshape((n,) * d)
      tensor = tl.tensor(tensor)
  
      tensor_shape = tensor.shape
  
      # Find TT decomposition of the tensor
      rank = [1, 3, 3, 1]
      factors = tensor_train_cross(
          tensor, rank, tol=1e-5, n_iter_max=10, random_state=1234
      )
      assert (
          len(factors) == d
      ), "Number of factors should be 4, currently has " + str(
          len(factors)
      )
  
      # Check that the ranks are correct and that the second mode of each factor
      # has the correct number of elements
      r_prev_iteration = 1
      for k in range(d):
          (r_prev_k, n_k, r_k) = factors[k].shape
          assert tensor_shape[k] == n_k, (
              "Mode 1 of factor "
              + str(k)
              + "needs "
              + str(tensor_shape[k])
              + " dimensions, currently has "
              + str(n_k)
          )
          assert (
              r_prev_k == r_prev_iteration
          ), " Incorrect ranks of factors "
          r_prev_iteration = r_k
  
file_path: tensorly/tensorly/contrib/decomposition/tests/test_mps_decomposition_cross.py
imports: import tensorly
  import pytest
  import numpy
  import itertools
  from .._tt_cross import tensor_train_cross
  from ....tt_tensor import tt_to_tensor
  from tensorly.testing import assert_
label_desc: Use image node_id 1 for calling a global function with example usage: test_tensor_train_cross_1() without return types