def forward(self, batch_C_prime, I_r_size):
        """
        Generate the grid for the grid_sampler.
        Args:
            batch_C_prime: the matrix of the geometric transformation
            I_r_size: the shape of the input image
        Return:
            batch_P_prime: the grid for the grid_sampler
        """
        C = self.build_C_paddle()
        P = self.build_P_paddle(I_r_size)

        inv_delta_C_tensor = self.build_inv_delta_C_paddle(C).type(torch.float32)
        P_hat_tensor = self.build_P_hat_paddle(
            C, torch.as_tensor(P)).type(torch.float32)

        inv_delta_C_tensor.stop_gradient = True
        P_hat_tensor.stop_gradient = True

        batch_C_ex_part_tensor = self.get_expand_tensor(batch_C_prime)

        batch_C_ex_part_tensor.stop_gradient = True

        batch_C_prime_with_zeros = torch.cat(
            [batch_C_prime, batch_C_ex_part_tensor], dim=1)
        inv_delta_C_tensor = inv_delta_C_tensor.to(batch_C_prime_with_zeros.device)
        batch_T = torch.matmul(inv_delta_C_tensor, batch_C_prime_with_zeros)
        P_hat_tensor = P_hat_tensor.to(batch_T.device)
        batch_P_prime = torch.matmul(P_hat_tensor, batch_T)
        return batch_P_prime

        Generate the grid for the grid_sampler.
        Args:
            batch_C_prime: the matrix of the geometric transformation
            I_r_size: the shape of the input image
        Return:
            batch_P_prime: the grid for the grid_sampler
        
pytorchocr/modeling/transforms/tps.py