I have created the following class and saved scripted_module and loaded in C++ API by:
    torch::jit::script::Module module;
    module = torch::jit::load("scriptmodule.pt");

Now, the question is how can I call func from C++?
import torch
import torch.nn as nn

class MyModule(nn.Module):
    def __init__(self):
        super(MyModule, self).__init__()

    @torch.jit.ignore
    def get_rand(self):
        return torch.randint(0, 2, size=[1])

    def forward(self):
        pass 
    
    @torch.jit.export
    def func(self):
        done = self.get_rand()
        print (done)

scripted_module = torch.jit.script(MyModule())