How to use a > operator on a number inside a tensor?

I have a 1D tensor of numbers in LibTorch, in C++ and I would like to evaluate each number with a > condition.

This is my attempt. Inside the if statement the condition is whether the ith tensor is greater than 0.5.

#include <torch/torch.h>
using namespace torch::indexing;

torch::Tensor frogs;   

int main() {

    frogs = torch::rand({11});

    for (int i = 0; i<10; ++i) {

        if (frogs.index({i}).item() > 0.5) {

            std::cout << frogs.index({i}).item() << " \n";
        }
    }   

    return 0;
}

It returns the error…

Consolidate compiler generated dependencies of target mujoco_gym
[ 50%] Building CXX object CMakeFiles/mujoco_gym.dir/tester.cpp.o
/home/iii/tor/m_gym/tester.cpp: In function ‘int main()’:
/home/iii/tor/m_gym/tester.cpp:18:37: error: no match for ‘operator>’ (operand types are ‘c10::Scalar’ and ‘double’)
   18 |         if (frogs.index({i}).item() > 0.5) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
      |                                  |    |
      |                                  |    double
      |                                  c10::Scalar
In file included from /home/iii/tor/m_gym/libtorch/include/c10/util/string_view.h:5,
                 from /home/iii/tor/m_gym/libtorch/include/c10/util/StringUtil.h:6,
                 from /home/iii/tor/m_gym/libtorch/include/c10/util/Exception.h:6,
                 from /home/iii/tor/m_gym/libtorch/include/c10/core/Device.h:5,
                 from /home/iii/tor/m_gym/libtorch/include/ATen/core/TensorBody.h:11,
                 from /home/iii/tor/m_gym/libtorch/include/ATen/core/Tensor.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/ATen/Tensor.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/autograd/function_hook.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/autograd/cpp_hook.h:2,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/autograd/variable.h:6,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/autograd/autograd.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/api/include/torch/autograd.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/api/include/torch/all.h:7,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
                 from /home/iii/tor/m_gym/tester.cpp:1:
/home/iii/tor/m_gym/libtorch/include/c10/util/reverse_iterator.h:200:23: note: candidate: ‘template<class _Iterator> constexpr bool c10::operator>(const c10::reverse_iterator<_Iterator>&, const c10::reverse_iterator<_Iterator>&)’
  200 | inline constexpr bool operator>(
      |                       ^~~~~~~~
/home/iii/tor/m_gym/libtorch/include/c10/util/reverse_iterator.h:200:23: note:   template argument deduction/substitution failed:
/home/iii/tor/m_gym/tester.cpp:18:39: note:   ‘c10::Scalar’ is not derived from ‘const c10::reverse_iterator<_Iterator>’
   18 |         if (frogs.index({i}).item() > 0.5) {
      |                                       ^~~
In file included from /home/iii/tor/m_gym/libtorch/include/c10/util/string_view.h:5,
                 from /home/iii/tor/m_gym/libtorch/include/c10/util/StringUtil.h:6,
                 from /home/iii/tor/m_gym/libtorch/include/c10/util/Exception.h:6,
                 from /home/iii/tor/m_gym/libtorch/include/c10/core/Device.h:5,
                 from /home/iii/tor/m_gym/libtorch/include/ATen/core/TensorBody.h:11,
                 from /home/iii/tor/m_gym/libtorch/include/ATen/core/Tensor.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/ATen/Tensor.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/autograd/function_hook.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/autograd/cpp_hook.h:2,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/autograd/variable.h:6,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/autograd/autograd.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/api/include/torch/autograd.h:3,

int main() {

    frogs = torch::rand({11});

    float* temp_arr = frogs.data_ptr<float>();


    for (int i = 0; i<10; ++i) {

        if (temp_arr[i] > 0.5) {

            std::cout << temp_arr[i] << " \n";
        }
     }   

    return 0;
}