<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def valid(a, b):
 """Check whether `a` and `b` are not inf or nan"""

    return ~(np.isnan(a) | np.isinf(a) | np.isnan(b) | np.isinf(b))