def load_model(self, state_dict, only_encoder):
    own_state = self.state_dict()
    for (k, v) in own_state.items():
        if (only_encoder and (('encoder' in k) or ('embed_refine_net' in k))):
            own_state[k] = state_dict[k]
        elif ((k in state_dict) and (k in own_state)):
            own_state[k] = state_dict[k]
    self.load_state_dict(own_state)
def load_model(self, state_dict, only_encoder):
    own_state = self.state_dict()
    for (k, v) in own_state.items():
        if (only_encoder and (('encoder' in k) or ('embed_refine_net' in k))):
            own_state[k] = state_dict[k]
        elif ((k in state_dict) and (k in own_state)):
            own_state[k] = state_dict[k]
    self.load_state_dict(own_state)