Not able to use the uploaded model in Hugginface

quoting from How to create a config.json after saving a model - #4 by BramVanroy

instead of

class modelWithLossFunc(nn.Module):

use

from transformers.modeling_utils import PreTrainedModel
class modelWithLossFunc(PreTrainedModel):