def get_initial_inputs(
        self,
        prompt: Union[Union[str, tuple[str]], list[Union[str, tuple[str]]]],
        template: Optional[str],
        use_io_binding: bool,
        cache_type: str,
        max_cache_len: int,
        cache_backend: str,
    ) -> tuple[dict[str, Union["NDArray", OrtValue]], Union["Cache", "IOBoundCache"]]:
        """Get the initial inputs and cache for the model."""
        if self.tokenizer.pad_token is None:
            self.tokenizer.pad_token = self.tokenizer.eos_token
        # using right padding since gqa expects it
        # other attention types should not care about padding side as long as the attention mask is correct
        self.tokenizer.padding_side = "right"

        if template is not None:
            prompt = (
                apply_template(template, prompt)
                if isinstance(prompt, (str, tuple))
                else [apply_template(template, p) for p in prompt]
            )
        else:
            assert isinstance(prompt, str) or (isinstance(prompt, list) and all(isinstance(p, str) for p in prompt)), (
                "tuple prompts require a template"
            )

        encodings_dict = self.tokenizer(prompt, return_tensors="np", padding=True)
        input_ids = encodings_dict["input_ids"].astype(self.input_info["input_ids"]["dtype"])
        batch_size, prompt_length = input_ids.shape
        attention_mask = encodings_dict["attention_mask"]
        if "attention_mask" in self.input_info:
            attention_mask = attention_mask.astype(self.input_info["attention_mask"]["dtype"])

        cache = self.get_fresh_cache(batch_size, use_io_binding, cache_type, max_cache_len, cache_backend)
        if isinstance(cache, GQASharedCache):
            attention_mask = np.concatenate(
                [attention_mask, np.zeros((batch_size, cache.max_cache_len - prompt_length), dtype=np.int32)], 1
            )

        inputs = {"input_ids": input_ids, "attention_mask": attention_mask}
        if self.use_position_ids:
            position_ids = np.arange(prompt_length, dtype=np.int64).reshape((1, prompt_length))
            position_ids = np.broadcast_to(position_ids, (batch_size, prompt_length))
            inputs["position_ids"] = position_ids.astype(self.input_info["position_ids"]["dtype"])
        if self.use_past_seq_len:
            inputs["past_seq_len"] = (attention_mask.sum(-1, keepdims=True) - 1).astype(np.int32)
            inputs["total_seq_len"] = np.array(attention_mask.shape[1], dtype=np.int32)
        if use_io_binding:
            inputs = {k: OrtValue.ortvalue_from_numpy(v, self.device, self.device_id) for k, v in inputs.items()}
        return inputs, cache
Get the initial inputs and cache for the model.
examples/utils/generator.py