Python 3 Code
\n\n# Code\npython3 []\nclass Solution:\n    def sumOfPower(self, nums: List[int], k: int) -> int:\n        MOD = 10**9 + 7\n\n        @lru_cache(None)  # Using
\n\n# Code\n```python3 []\nclass Solution:\n    def sumOfPower(self, nums: List[int], k: int) -> int:\n        MOD = 10**9 + 7\n\n        @lru_cache(None)  # Using built-in Python LRU cache for memoization\n        def solve(i, current_sum, count):\n            if current_sum == k:  # If we hit the target sum\n                return pow(2, len(nums) - count, MOD)  # Efficient exponentiation modulo\n            if i >= len(nums) or current_sum > k:  # Out of bounds or exceeded the sum\n                return 0\n\n            # Recursive cases: take or skip the current number\n            take = solve(i + 1, current_sum + nums[i], count + 1)\n            not_take = solve(i + 1, current_sum, count)\n\n            return (take + not_take) % MOD\n\n        return solve(0, 0, 0)\n\n```
['Python3']