def load_model(self, state_dict, own_rel_in_input, own_cls_in_input, pre_rel_in_input, pre_cls_in_input):
    own_state = self.state_dict()
    for (k, v) in own_state.items():
        if (k == 'pos_embedding.pos_embedding.weight'):
            own_pos_size = v.size(0)
            seq_len = ((own_pos_size - own_rel_in_input) - own_cls_in_input)
            pretrained_pos_size = state_dict[k].size(0)
            own_start_ind = int((own_rel_in_input + own_cls_in_input))
            pre_start_ind = int((pre_rel_in_input + pre_cls_in_input))
            seq_len = min(seq_len, (state_dict[k].size(0) - pre_start_ind))
            own_state[k][own_start_ind:(own_start_ind + seq_len)] = state_dict[k][pre_start_ind:(pre_start_ind + seq_len)]
            if (own_rel_in_input and own_cls_in_input):
                if (pre_cls_in_input and pre_cls_in_input):
                    own_state[k][:2] = state_dict[k][:2]
                elif pre_cls_in_input:
                    own_state[k][1] = state_dict[k][0]
                elif pre_rel_in_input:
                    own_state[k][0] = state_dict[k][0]
            elif own_rel_in_input:
                if pre_rel_in_input:
                    own_state[k][0] = state_dict[k][0]
            elif own_cls_in_input:
                if pre_cls_in_input:
                    own_state[k][0] = state_dict[k][int(pre_rel_in_input)]
        else:
            own_state[k] = state_dict[k]
    self.load_state_dict(own_state)
def load_model(self, state_dict, own_rel_in_input, own_cls_in_input, pre_rel_in_input, pre_cls_in_input):
    own_state = self.state_dict()
    for (k, v) in own_state.items():
        if (k == 'pos_embedding.pos_embedding.weight'):
            own_pos_size = v.size(0)
            seq_len = ((own_pos_size - own_rel_in_input) - own_cls_in_input)
            pretrained_pos_size = state_dict[k].size(0)
            own_start_ind = int((own_rel_in_input + own_cls_in_input))
            pre_start_ind = int((pre_rel_in_input + pre_cls_in_input))
            seq_len = min(seq_len, (state_dict[k].size(0) - pre_start_ind))
            own_state[k][own_start_ind:(own_start_ind + seq_len)] = state_dict[k][pre_start_ind:(pre_start_ind + seq_len)]
            if (own_rel_in_input and own_cls_in_input):
                if (pre_cls_in_input and pre_cls_in_input):
                    own_state[k][:2] = state_dict[k][:2]
                elif pre_cls_in_input:
                    own_state[k][1] = state_dict[k][0]
                elif pre_rel_in_input:
                    own_state[k][0] = state_dict[k][0]
            elif own_rel_in_input:
                if pre_rel_in_input:
                    own_state[k][0] = state_dict[k][0]
            elif own_cls_in_input:
                if pre_cls_in_input:
                    own_state[k][0] = state_dict[k][int(pre_rel_in_input)]
        else:
            own_state[k] = state_dict[k]
    self.load_state_dict(own_state)