code: def _expand_mask(
      mask: torch.Tensor,
      dtype: torch.dtype,
      tgt_len: Optional[int] = None,
  ):
      """
      Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
      """
      bsz, src_len = mask.size()
      tgt_len = tgt_len if tgt_len is not None else src_len
  
      expanded_mask = (
          mask[:, None, None, :]
          .expand(bsz, 1, tgt_len, src_len)
          .to(dtype)
      )
  
      inverted_mask = 1.0 - expanded_mask
  
      return inverted_mask.masked_fill(
          inverted_mask.to(torch.bool), torch.finfo(dtype).min
      )
  
imports: import random
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, QuestionAnsweringModelOutput, SequenceClassifierOutputWithPast
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_opt import OPTConfig
label_desc: Use image node_id 3 for calling a global function with example usage: _expand_mask(mask, dtype, tgt_len) and returns: inverted_mask