code: def forward_bert_with_task_idx(self, sample_list):
      bert = self.bert_model.module
      input_ids = sample_list.input_ids
      attention_mask = sample_list.input_mask
      token_type_ids = sample_list.segment_ids
      device = input_ids.device
  
      position_ids = torch.arange(
          input_ids.size(1), dtype=torch.long, device=device
      )
  
      input_shape = input_ids.size()
  
      if attention_mask is None:
          attention_mask = torch.ones(input_shape, device=device)
      if token_type_ids is None:
          token_type_ids = torch.zeros(
              input_shape, dtype=torch.long, device=device
          )
  
      embedding_output = bert.embeddings(
          input_ids=input_ids,
          position_ids=position_ids,
          token_type_ids=token_type_ids,
      )
  
      start_idx = 0
      if self.config.base_args.use_task_embedding_in_lang_encoder:
          bs = input_ids.size(0)
          task_idx = self.get_task_idx(sample_list.dataset_name)
          task_embed = self.task_embeddings_lang.weight[task_idx]
          task_embed = (
              task_embed.unsqueeze(0).unsqueeze(0).repeat(bs, 1, 1)
          )
          embedding_output = torch.cat(
              [task_embed, embedding_output], dim=1
          )
          task_attention_mask = embedding_output.new_ones((bs, 1))
          attention_mask = torch.cat(
              [task_attention_mask, attention_mask], dim=1
          )
          start_idx = 1
  
      extended_attention_mask = attention_mask.unsqueeze(1).unsqueeze(2)
      extended_attention_mask = extended_attention_mask.to(
          dtype=next(self.parameters()).dtype
      )  # fp16 compatibility
      extended_attention_mask = (
          1.0 - extended_attention_mask
      ) * -10000.0
      head_mask = [None for _ in range(bert.config.num_hidden_layers)]
      encoder_outputs = bert.encoder(
          embedding_output,
          attention_mask=extended_attention_mask,
          head_mask=head_mask,
      )
      sequence_output = encoder_outputs[0][:, start_idx:, :]
      pos_embeddings = self.bert_model.embeddings.position_embeddings(
          position_ids
      )
  
      return sequence_output, pos_embeddings
  
imports: import logging
  from copy import deepcopy
  from typing import Dict
  import torch
  from mmf.common.registry import registry
  from mmf.models import BaseModel
  from mmf.models.unit.unit_base_model import AttributeHead, build_detection_loss, MLP, UniTBaseModel
  from mmf.modules.encoders import TransformerEncoder
  from mmf.utils.distributed import byte_tensor_to_object
  from torch import nn, Tensor
label_desc: Use image node_id 5 for calling the UniT obj's underlying member method code with example usage: obj.forward_bert_with_task_idx(sample_list) and returns: sequence_output,  pos_embeddings