This function should accept a context and a map of integers where the keys are integers and the values represent weights or thresholds.
It should return a randomly selected key from the map, with the probability of each key being selected proportional to its associated value (weight). For example, a key with a higher weight should have a greater chance of being chosen than a key with a lower weight.
If the map is empty, the function should return an error indicating that the input is invalid.
Intn(ctx context.Context, n int) int:
This function should accept a context and an integer n, and return a pseudo-random integer in the range [0, n).
The random number generation should be seeded using a seed that is set through a separate function WithSeed(ctx context.Context, seed string) context.Context, where the seed influences the randomness of the result.
If n is less than or equal to 0, the function should return an error indicating that the input is invalid.
Ensure that implementing these functions will make all associated tests pass as provided in the test code.
Important: declare your solution in package random (the test file uses package random, so the implementation must use the matching package name).