# How to get all 2D diagonals of a 3D NumPy array in Python # Import the numpy packageimport numpy as np  # Create 3D-numpy array# of 4 rows and 4 columnsarr = np.arange(3 * 4 * 4).reshape(3, 4, 4)  print("Original 3d array:\n",       arr)  # Create 2D diagonal arraydiag_arr = np.diagonal(arr,                        axis1 = 1,                       axis2 = 2)  print("2d diagonal array:\n",       diag_arr)