MaskedLMOutput does not have last_hidden_state
I am trying to access the last hidden state here atpooler1andpooler2variables towards the end of the code.class BERT_Arch(nn.Module):

    def __init__(self, bert):
      
      super(BERT_Arch, self).__init__()

      self.bert = MODEL_TYPE.from_pretrained(PRETRAINED_MODEL_NAME)
      freeze(self.bert, params['freeze']) 
      for name, param in self.bert.named_parameters():
        print("{} -> {}".format(name, param.requires_grad))

      self.dropout = nn.Dropout(params['dropout'])
      self.relu =  nn.ReLU()
      self.fc1 = nn.Linear(params['linear_in'], params['linear_out'])

      def _qa_embedding(self, pooler):
         x = self.fc1(pooler)
         x = normalize_vectors(x)
         return x

      #define the forward pass
      def forward(self, tokensq, maskq, tokens1, mask1, tokens2, mask2):

      #pass the inputs to the model  
      outputs1 = self.bert(torch.cat((tokensq, tokens1), 1), attention_mask=torch.cat((maskq, mask1), 1), output_hidden_states=True)
      outputs2 = self.bert(torch.cat((tokensq, tokens2), 1), attention_mask=torch.cat((maskq, mask2), 1), output_hidden_states=True)

      # last_hidden_state does only exist with the non "auto-masked" models use hidden_states for the rest
      pooler1 = torch.cat((outputs1.last_hidden_state[:,0], outputs1.last_hidden_state[:,params['max_q_len']]), 1)
      pooler2 = torch.cat((outputs2.last_hidden_state[:,0], outputs2.last_hidden_state[:,params['max_q_len']]), 1)

      v1 = self._qa_embedding(pooler1)
      v2 = self._qa_embedding(pooler2)
      
      return v1, v2It did work when I used this BERT multiling uncased which usesBaseModelOutput.last_hidden_stateis declared as avariable.Unfortunately, now that I am using BERT mutliling cased, the classMaskedLMOutputis being used which does not seem to have thelast_hidden_statevariable.How can I access thelast_hidden_state?Do I really need to copy theclass MaskedLMOutputincluding all the dependencies and addlast_hidden_state: torch.FloatTensor = None? It seems a bit overkill as I need to import all the dependencies then.Thanks so much