import tensorflow as tf

  """

  # TODO: support shape and tt_ranks as TensorShape?.
  # TODO: support None as a dimension.
  shape = np.array(shape)
  tt_rank = np.array(tt_rank)
  _validate_input_parameters(is_tensor=True, shape=shape, tt_rank=tt_rank,
                             batch_size=batch_size)
  num_dims = shape.size
  if tt_rank.size == 1:
    tt_rank = tt_rank * np.ones(num_dims - 1)
    tt_rank = np.insert(tt_rank, 0, 1)
    tt_rank = np.append(tt_rank, 1)
  tt_rank = tt_rank.astype(int)
  tt_cores = [None] * num_dims
  with tf.name_scope(name):
    for i in range(num_dims):
      curr_core_shape = (batch_size, tt_rank[i], shape[i], tt_rank[i + 1])
      tt_cores[i] = tf.random_normal(curr_core_shape, mean=mean, stddev=stddev,
                                     dtype=dtype)

    return TensorTrainBatch(tt_cores, shape, tt_rank, batch_size)


def matrix_with_random_cores(shape, tt_rank=2, mean=0., stddev=1.,
                             dtype=tf.float32,
                             name='t3f_matrix_with_random_cores'):
  """Generate a TT-matrix of given shape with N(mean, stddev^2) cores.

  Args:
