<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def substitute_array(a, d):
 """ Apply ``substitute`` to all elements of an array ``a`` and return the resulting array. :param Union[np.array,List] a: The expression array to substitute. :param Dict[Parameter,Union[int,float]] d: Numerical substitutions for parameters. :return: An array of partially substituted Expressions or numbers. :rtype: np.array """

    a = np.asarray(a, order="C")
    return np.array([substitute(v, d) for v in a.flat]).reshape(a.shape)