class_docstr: Decoder model with a language modeling head on top for ONNX Runtime inference.
class_docstr_tok: ["Decoder","model","with","a","language","modeling","head","on","top","for","ONNX","Runtime","inference","."]
code: def prepare_inputs_for_merged(
      self,
      input_ids: Union[None, torch.LongTensor, np.ndarray],
      past_key_values: Union[
          None, Tuple[torch.FloatTensor], Tuple[np.ndarray]
      ],
      use_torch: bool,
  ):
      if self.parent_model.use_merged:
          constructor = torch if use_torch is True else np
          # Uses without/with branch of a merged decoder depending on whether real past key values are passed
          use_cache_branch = constructor.full(
              (1,), past_key_values is not None
          )
      else:
          # Uses separate decoders
          use_cache_branch = None
  
      if use_torch and use_cache_branch is not None:
          use_cache_branch = use_cache_branch.to(self.device)
  
      # Generate dummy past for the first forward if uses a merged decoder
      if self.parent_model.use_merged and past_key_values is None:
          batch_size = input_ids.shape[0]
          num_attention_heads = (
              self.normalized_config.num_attention_heads
          )
          embed_size_per_head = (
              self.normalized_config.hidden_size // num_attention_heads
          )
          dtype = (
              constructor.float16
              if self.use_fp16
              else constructor.float32
          )
          shape = (
              batch_size,
              num_attention_heads,
              1,
              embed_size_per_head,
          )
          key_or_value = constructor.zeros(shape, dtype=dtype)
  
          if use_torch is True:
              key_or_value = key_or_value.to(self.device)
  
          past_key_values = tuple(
              key_or_value
              for _ in range(len(self.key_value_input_names))
          )
  
      return use_cache_branch, past_key_values
  
imports: from abc import abstractmethod
  from typing import TYPE_CHECKING, Dict, Optional, Set, Tuple, Union
  import numpy
  import torch
  from transformers.modeling_outputs import BaseModelOutput, Seq2SeqLMOutput
  from onnxruntime import InferenceSession
  from ..utils import NormalizedConfigManager
  from ..utils.logging import warn_once
  from .utils import get_ordered_input_names, logging
label_desc: Use image node_id 5 for calling the ORTDecoderForSeq2Seq obj's underlying member method code with example usage: obj.prepare_inputs_for_merged(input_ids, past_key_values, use_torch) and returns: use_cache_branch,  past_key_values