code: def prepare_inputs_for_generation(
      self,
      input_ids,
      past_key_values=None,
      inputs_embeds=None,
      **kwargs,
  ):
      token_type_ids = kwargs.get("token_type_ids", None)
      # Omit tokens covered by past_key_values
      if past_key_values:
          if self.config.multi_query:
              past_length = past_key_values[0].shape[1]
          else:
              past_length = past_key_values[0].shape[2]
  
          # Some generation methods already pass only the last input ID
          if input_ids.shape[1] > past_length:
              remove_prefix_length = past_length
          else:
              # Default to old behavior: keep only final ID
              remove_prefix_length = input_ids.shape[1] - 1
  
          input_ids = input_ids[:, remove_prefix_length:]
          if token_type_ids is not None:
              token_type_ids = token_type_ids[:, -input_ids.shape[1] :]
  
      attention_mask = kwargs.get("attention_mask", None)
      position_ids = kwargs.get("position_ids", None)
  
      if attention_mask is not None and position_ids is None:
          # create position_ids on the fly for batch generation
          position_ids = attention_mask.long().cumsum(-1) - 1
          position_ids.masked_fill_(attention_mask == 0, 1)
          if past_key_values:
              position_ids = position_ids[:, -input_ids.shape[1] :]
      else:
          position_ids = None
  
      # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
      if inputs_embeds is not None and past_key_values is None:
          model_inputs = {"inputs_embeds": inputs_embeds}
      else:
          model_inputs = {"input_ids": input_ids}
  
      model_inputs.update(
          {
              "past_key_values": past_key_values,
              "use_cache": kwargs.get("use_cache"),
              "position_ids": position_ids,
              "attention_mask": attention_mask,
              "token_type_ids": token_type_ids,
          }
      )
      return model_inputs
  
imports: import math
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn.functional
  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 AttentionMaskConverter
  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, is_flash_attn_2_available, is_flash_attn_greater_or_equal_2_10, logging
  from .configuration_gpt_bigcode import GPTBigCodeConfig
label_desc: Use image node_id 4 for calling the GPTBigCodeForCausalLM obj's underlying member method code with example usage: obj.prepare_inputs_for_generation(input_ids, past_key_values, inputs_embeds) and returns: model_inputs