<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _is_2D_matrix(matrix):
 """Checks to see if a ndarray is 2D or a list of lists is 2D"""

    return ((isinstance(matrix[0], list) and _rectangular(matrix) and
             not isinstance(matrix[0][0], list)) or
            (not isinstance(matrix, list) and matrix.shape == 2))