docstr: labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
      Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
      `labels = input_ids` Indices are selected in `[-100, 0, ..., config.vocab_size]` All labels set to `-100`
      are ignored (masked), the loss is only computed for labels in `[0, ..., config.vocab_size]`
docstr_tok: ["labels","(","`","torch.LongTensor","`","of","shape","`","(","batch_size",",","sequence_length",")","`",",","*","optional","*",")",":","Labels","for","language","modeling",".","Note","that","the","labels","*","*","are","shifted","*","*","inside","the","model",",","i.e",".","you","can","set","`","labels","=","input_ids","`","Indices","are","selected","in","`","[","-100",",","0",",","...",",","config.vocab_size","]","`","All","labels","set","to","`","-100","`","are","ignored","(","masked",")",",","the","loss","is","only","computed","for","labels","in","`","[","0",",","...",",","config.vocab_size","]","`"]
code: def forward(
      self,
      input_ids: Optional[torch.LongTensor] = None,
      attention_mask: Optional[torch.FloatTensor] = None,
      head_mask: Optional[torch.FloatTensor] = None,
      inputs_embeds: Optional[torch.FloatTensor] = None,
      past_key_values: Optional[Tuple[Tuple[torch.Tensor]]] = 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, CausalLMOutputWithCrossAttentions]:
      r"""
      labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
          Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
          `labels = input_ids` Indices are selected in `[-100, 0, ..., config.vocab_size]` All labels set to `-100`
          are ignored (masked), the loss is only computed for labels in `[0, ..., config.vocab_size]`
      """
      return_dict = (
          return_dict
          if return_dict is not None
          else self.config.use_return_dict
      )
  
      outputs = self.biogpt(
          input_ids,
          attention_mask=attention_mask,
          head_mask=head_mask,
          inputs_embeds=inputs_embeds,
          past_key_values=past_key_values,
          use_cache=use_cache,
          output_attentions=output_attentions,
          output_hidden_states=output_hidden_states,
          return_dict=return_dict,
      )
  
      sequence_output = outputs[0]
      prediction_scores = self.output_projection(sequence_output)
  
      lm_loss = None
      if labels is not None:
          # we are doing next-token prediction; shift prediction scores and input ids by one
          shifted_prediction_scores = prediction_scores[
              :, :-1, :
          ].contiguous()
          labels = labels[:, 1:].contiguous()
          loss_fct = CrossEntropyLoss()
          lm_loss = loss_fct(
              shifted_prediction_scores.view(
                  -1, self.config.vocab_size
              ),
              labels.view(-1),
          )
  
      if not return_dict:
          output = (prediction_scores,) + outputs[1:]
          return (
              ((lm_loss,) + output) if lm_loss is not None else output
          )
  
      return CausalLMOutputWithCrossAttentions(
          loss=lm_loss,
          logits=prediction_scores,
          past_key_values=outputs.past_key_values,
          hidden_states=outputs.hidden_states,
          attentions=outputs.attentions,
          cross_attentions=outputs.cross_attentions,
      )
  
imports: import math
  from typing import 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_attn_mask_utils import _prepare_4d_causal_attention_mask
  from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, SequenceClassifierOutputWithPast, TokenClassifierOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
  from .configuration_biogpt import BioGptConfig
label_desc: Use image node_id 4 for calling the BioGptForCausalLM obj's underlying member method code with example usage: obj.forward(input_ids, attention_mask, head_mask, inputs_embeds, past_key_values, labels, use_cache, output_attentions, output_hidden_states, return_dict) and returns: CausalLMOutputWithCrossAttentions, unknown