how to find the mean and standard deviation of trqiing dataset in pytorch

#include <iostream>
#include <cmath>
#include <torch/torch.h>

int main() {
  torch::manual_seed(1);

  // Create a random dataset
  auto data = torch::randn({1000});

  // Calculate the mean
  auto mean = torch::mean(data).item<float>();
  std::cout << "Mean: " << mean << std::endl;

  // Calculate the standard deviation
  auto variance = torch::var(data, false).item<float>();
  auto std_dev = std::sqrt(variance);
  std::cout << "Standard Deviation: " << std_dev << std::endl;

  return 0;
}