import tensorflow as tf

  if tt_rank.size == 1:
    tt_rank = tt_rank * np.ones(num_dims - 1)
    tt_rank = np.concatenate([[1], tt_rank, [1]])

  shape = shape.astype(int)
  tt_rank = tt_rank.astype(int)

  cr_exponent = -1.0 / (2 * num_dims)
  var = np.prod(tt_rank ** cr_exponent)
  core_stddev = stddev ** (1.0 / num_dims) * var
  with tf.name_scope(name):
    tt = matrix_batch_with_random_cores(shape, tt_rank=tt_rank,
                                        stddev=core_stddev,
                                        batch_size=batch_size,
                                        dtype=dtype)

  if np.abs(mean) < 1e-8:
    return tt
  else:
    raise NotImplementedError('non-zero mean is not supported yet')
