@ptrblck. Following your suggestions,
I have tried doing
model = LayoutlmModel.from_pretrained(“microsoft/layoutlm-base-uncased”)
then
model.load_state_dict(torch.load(‘pytorch_model.bin’, map_location=‘cpu’))
Following error comes
RuntimeError: Error(s) in loading state_dict for LayoutlmModel:
Missing key(s) in state_dict: “embeddings.word_embeddings.weight”, “embeddings.position_embeddings.weight”, “embeddings.x_position_embeddings.weight”, “embeddings.y_position_embeddings.weight”, …
but both the keys in state_dict(pytorch_model.bin)  and the keys in the model are same then why this error is shown?
PS : model = LayoutlmModel.from_pretrained(“microsoft/layoutlm-base-uncased”,state_dict=torch.load(‘pytorch_model.bin’, map_location=‘cpu’)). This has worked for me.
Thank you @ptrblck . Your suggestions were valuable.