code: def bert_extended_attention_mask(attention_mask):
      # We create a 3D attention mask from a 2D tensor mask.
      # [b, 1, s]
      attention_mask_b1s = attention_mask.unsqueeze(1)
      # [b, s, 1]
      attention_mask_bs1 = attention_mask.unsqueeze(2)
      # [b, s, s]
      attention_mask_bss = attention_mask_b1s * attention_mask_bs1
      # [b, 1, s, s]
      extended_attention_mask = attention_mask_bss.unsqueeze(1)
  
      # Convert attention mask to binary:
      extended_attention_mask = extended_attention_mask < 0.5
  
      return extended_attention_mask
  
file_path: NeMo/nemo/collections/nlp/models/language_modeling/megatron/bert_model.py
imports: import torch
  from nemo.collections.nlp.modules.common.megatron.language_model import get_language_model
  from nemo.collections.nlp.modules.common.megatron.module import MegatronModule
  from nemo.collections.nlp.modules.common.megatron.transformer import get_layer_norm
  from nemo.collections.nlp.modules.common.megatron.utils import ApexGuardDefaults, build_position_ids, erf_gelu, get_linear_layer, init_method_normal, openai_gelu, parallel_lm_logits, scaled_init_method_normal
label_desc: Use image node_id 1 for calling a global function with example usage: bert_extended_attention_mask(attention_mask) and returns: extended_attention_mask