Inference for OGM using UGM