Are there any algorithms that learn to learn a function mapping? Typical algorithms involve learning and applying a single mapping e.g. $ f: X \mapsto Y$

Are there any algorithms that learn multiple mappings given an extra variable e.g. $ f(Z): X \mapsto Y$
(This feels like an abuse of notation.).

Here we learn a mapping, given $Z$, that is then applied to $X$ to produce $Y$

One solution (although intractable) would be to train an algorithm (e.g. a neural network) whose output is then used as the weights of a second network. 

Any suggestions would be much appreciated and feel free to ask for more details. Thanks.
This is equivalent to thinking of this as learning a function of two inputs, i.e.,  $g : (X,Z) \mapsto Y$ (i.e., $g(X,Z)=Y$).  Any machine learning method for learning functions can be used for that; you just treat the feature vector (the input) as the concatenation of the vector $X$ and the vector $Z$, and then use standard ML techniques on the resulting instances.  So, you don't need anything special or fancy to handle this -- you can use any existing machine learning method that you are comfortable with.