src/transformers/models/gpt2/configuration_gpt2.py/GPT2OnnxConfig/generate_dummy_inputs
class GPT2OnnxConfig:    def generate_dummy_inputs(
        self,
        tokenizer: PreTrainedTokenizer,
        batch_size: int = -1,
        seq_length: int = -1,
        is_pair: bool = False,
        framework: Optional[TensorType] = None,
    ) -> Mapping[str, Any]:
        common_inputs = super().generate_dummy_inputs(tokenizer, batch_size, seq_length, is_pair, framework)

        # We need to order the input in the way they appears in the forward()
        ordered_inputs = OrderedDict({"input_ids": common_inputs["input_ids"]})

        # Need to add the past_keys
        if self.use_past:
            if not is_torch_available():
                raise ValueError("Cannot generate dummy past_keys inputs without PyTorch installed.")
            else:
                import torch

                batch = common_inputs["input_ids"].shape[0]
                ordered_inputs["past_key_values"] = [
                    (
                        torch.zeros((batch, self._config.n_head, 1, self._config.hidden_size // self._config.n_head)),
                        torch.zeros((batch, self._config.n_head, 1, self._config.hidden_size // self._config.n_head)),
                    )
                    for _ in range(self._config.n_layer)
                ]

        ordered_inputs["attention_mask"] = common_inputs["attention_mask"]
        return ordered_inputs