Solution for the given Query (GRU) is
#include <torch/torch.h>
#include <torch/script.h>
#include <iostream>
#include <memory>
#include <dirent.h>

#include <typeinfo>

using namespace std;

int main(int argc, const char* argv[]) {
  
  // Create the device we pass around based on whether CUDA is available.
  torch::Device device(torch::kCPU);
  if (torch::cuda::is_available()) {
    std::cout << "CUDA is available! Training on GPU." << std::endl;
    device = torch::Device(torch::kCUDA);
  }

  if (argc != 2) {
    std::cerr << "usage: LMtesting <path-to-exported-script-module>\n";
    return -1;
  }

  torch::jit::script::Module module;
  try {
    // Deserialize the ScriptModule from a file using torch::jit::load().
    module = torch::jit::load(argv[1]);
  }
  catch (const c10::Error& e) {
    std::cerr << "error loading the model\n";
    return -1;
  }

  std::cout << "ok\n";
  std::cout << "Language Model\n\n";

  // Hyper parameters
  int64_t embed_size = 100;
  int64_t hidden_size = 100;
  int64_t num_layers = 2;
  int64_t num_samples = 1000;  // the number of words to be sampled
  int64_t batch_size = 20;
  int64_t sequence_length = 35;
  int64_t num_epochs = 2;
  double learning_rate = 20;

  

  //module->eval();

  
  torch::Tensor indata1 = torch::zeros({sequence_length,batch_size}, torch::kLong);


  vector<torch::jit::IValue> inputs;
  vector<float> data(sequence_length*batch_size, 1.0);
  torch::Tensor data_tensor = torch::from_blob(data.data(), {sequence_length,batch_size}).cuda();
  torch::Tensor h0 = torch::from_blob(std::vector<float>(num_layers* batch_size * hidden_size, 0.0).data(), {num_layers, batch_size, hidden_size}).cuda();


 
  torch::Tensor output = module.forward({data_tensor, h0}).toTensor().cuda();
  
}