def _generate(self, query_tensors: torch.Tensor) -> torch.Tensor:
        """
        **Overview:**
            Generate responses for a list of query tensors.
        **Arguments:**
            - query_tensors (torch.Tensor): A list of query tensors to generate responses for.
        """
        # Add the batch_size dimension to the original input. Shape: [T, N] -> [1, T, N]
        query_tensors = query_tensors.unsqueeze(0)
        # Generate the corresponding mask tensor.
        batch_mask = torch.ones_like(query_tensors)
        inputs = {"input_ids": query_tensors, "attention_mask": batch_mask}

        # Call the ``generate()`` API of GPT-2.
        generation = self.model.generate(**inputs, **self.generation_kwargs,
                                         pad_token_id=self.tokenizer.eos_token_id)

        # Remove prompt from the total completed sentence.
        output = generation[0, batch_mask[0].sum():]
        return output

        **Overview:**
            Generate responses for a list of query tensors.
        **Arguments:**
            - query_tensors (torch.Tensor): A list of query tensors to generate responses for.
        
chapter8_large/lm_env.py