docstr: labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
      Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
      config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
      (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
  
  Returns:
docstr_tok: ["labels","(","`","torch.LongTensor","`","of","shape","`","(","batch_size",",","sequence_length",")","`",",","*","optional","*",")",":","Labels","for","computing","the","masked","language","modeling","loss",".","Indices","should","either","be","in","`","[","0",",","...",",","config.vocab_size","]","`","or","-100","(","see","`","input_ids","`","docstring",")",".","Tokens","with","indices","set","to","`","-100","`","are","ignored","(","masked",")",",","the","loss","is","only","computed","for","the","tokens","with","labels","in","`","[","0",",","...",",","config.vocab_size","]","`",".","Returns",":"]
code: def forward(
      self,
      input_ids: Optional[torch.LongTensor] = None,
      attention_mask: Optional[torch.Tensor] = None,
      decoder_input_ids: Optional[torch.LongTensor] = None,
      decoder_attention_mask: Optional[torch.LongTensor] = None,
      head_mask: Optional[torch.Tensor] = None,
      decoder_head_mask: Optional[torch.Tensor] = None,
      cross_attn_head_mask: Optional[torch.Tensor] = None,
      encoder_outputs: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
      past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
      inputs_embeds: Optional[torch.FloatTensor] = None,
      decoder_inputs_embeds: Optional[torch.FloatTensor] = None,
      labels: Optional[torch.LongTensor] = None,
      use_cache: Optional[bool] = None,
      output_attentions: Optional[bool] = None,
      output_hidden_states: Optional[bool] = None,
      return_dict: Optional[bool] = None,
  ) -> Union[Tuple[torch.Tensor], Seq2SeqLMOutput]:
      r"""
      labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
          Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
          config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
          (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
  
      Returns:
      """
      return_dict = (
          return_dict
          if return_dict is not None
          else self.config.use_return_dict
      )
  
      if labels is not None:
          if decoder_input_ids is None:
              decoder_input_ids = shift_tokens_right(
                  labels,
                  self.config.pad_token_id,
                  self.config.decoder_start_token_id,
              )
  
      outputs = self.model(
          input_ids,
          attention_mask=attention_mask,
          decoder_input_ids=decoder_input_ids,
          encoder_outputs=encoder_outputs,
          decoder_attention_mask=decoder_attention_mask,
          head_mask=head_mask,
          decoder_head_mask=decoder_head_mask,
          cross_attn_head_mask=cross_attn_head_mask,
          past_key_values=past_key_values,
          inputs_embeds=inputs_embeds,
          decoder_inputs_embeds=decoder_inputs_embeds,
          use_cache=use_cache,
          output_attentions=output_attentions,
          output_hidden_states=output_hidden_states,
          return_dict=return_dict,
      )
      lm_logits = self.lm_head(outputs[0])
  
      masked_lm_loss = None
      if labels is not None:
          # move labels to the correct device to enable PP
          labels = labels.to(lm_logits.device)
          loss_fct = CrossEntropyLoss()
          masked_lm_loss = loss_fct(
              lm_logits.view(-1, self.config.vocab_size),
              labels.view(-1),
          )
  
      if not return_dict:
          output = (lm_logits,) + outputs[1:]
          return (
              ((masked_lm_loss,) + output)
              if masked_lm_loss is not None
              else output
          )
  
      return Seq2SeqLMOutput(
          loss=masked_lm_loss,
          logits=lm_logits,
          past_key_values=outputs.past_key_values,
          decoder_hidden_states=outputs.decoder_hidden_states,
          decoder_attentions=outputs.decoder_attentions,
          cross_attentions=outputs.cross_attentions,
          encoder_last_hidden_state=outputs.encoder_last_hidden_state,
          encoder_hidden_states=outputs.encoder_hidden_states,
          encoder_attentions=outputs.encoder_attentions,
      )
  
imports: import math
  from typing import List, Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.nn import CrossEntropyLoss
  from ...activations import ACT2FN
  from ...integrations.deepspeed import is_deepspeed_zero3_enabled
  from ...modeling_attn_mask_utils import _prepare_4d_attention_mask, _prepare_4d_causal_attention_mask
  from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, Seq2SeqLMOutput, Seq2SeqModelOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_code_sample_docstrings, add_end_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_m2m_100 import M2M100Config
label_desc: Use image node_id 6 for calling the M2M100ForConditionalGeneration obj's underlying member method code with example usage: obj.forward(input_ids, attention_mask, decoder_input_ids, decoder_attention_mask, head_mask, decoder_head_mask, cross_attn_head_mask, encoder_outputs, past_key_values, inputs_embeds, decoder_inputs_embeds, labels, use_cache, output_attentions, output_hidden_states, return_dict) and returns: Seq2SeqLMOutput, unknown