import numpy as np

a_2d = np.arange(6).reshape(2, 3)
print(a_2d)
# [[0 1 2]
#  [3 4 5]]

a_2d_flip = np.flip(a_2d)
print(a_2d_flip)
# [[5 4 3]
#  [2 1 0]]

print(np.shares_memory(a_2d, a_2d_flip))
# True

print(a_2d[::-1, ::-1])
# [[5 4 3]
#  [2 1 0]]

a_1d = np.arange(3)
print(a_1d)
# [0 1 2]

print(np.flip(a_1d))
# [2 1 0]

print(a_1d[::-1])
# [2 1 0]

a_3d = np.arange(24).reshape(2, 3, 4)
print(a_3d)
# [[[ 0  1  2  3]
#   [ 4  5  6  7]
#   [ 8  9 10 11]]
# 
#  [[12 13 14 15]
#   [16 17 18 19]
#   [20 21 22 23]]]

print(np.flip(a_3d))
# [[[23 22 21 20]
#   [19 18 17 16]
#   [15 14 13 12]]
# 
#  [[11 10  9  8]
#   [ 7  6  5  4]
#   [ 3  2  1  0]]]

print(a_3d[::-1, ::-1, ::-1])
# [[[23 22 21 20]
#   [19 18 17 16]
#   [15 14 13 12]]
# 
#  [[11 10  9  8]
#   [ 7  6  5  4]
#   [ 3  2  1  0]]]

print(np.flip(a_3d, 0))
# [[[12 13 14 15]
#   [16 17 18 19]
#   [20 21 22 23]]
# 
#  [[ 0  1  2  3]
#   [ 4  5  6  7]
#   [ 8  9 10 11]]]

print(a_3d[::-1])
# [[[12 13 14 15]
#   [16 17 18 19]
#   [20 21 22 23]]
# 
#  [[ 0  1  2  3]
#   [ 4  5  6  7]
#   [ 8  9 10 11]]]

print(np.flipud(a_3d))
# [[[12 13 14 15]
#   [16 17 18 19]
#   [20 21 22 23]]
# 
#  [[ 0  1  2  3]
#   [ 4  5  6  7]
#   [ 8  9 10 11]]]

print(np.flip(a_3d, 1))
# [[[ 8  9 10 11]
#   [ 4  5  6  7]
#   [ 0  1  2  3]]
# 
#  [[20 21 22 23]
#   [16 17 18 19]
#   [12 13 14 15]]]

print(a_3d[:, ::-1])
# [[[ 8  9 10 11]
#   [ 4  5  6  7]
#   [ 0  1  2  3]]
# 
#  [[20 21 22 23]
#   [16 17 18 19]
#   [12 13 14 15]]]

print(np.fliplr(a_3d))
# [[[ 8  9 10 11]
#   [ 4  5  6  7]
#   [ 0  1  2  3]]
# 
#  [[20 21 22 23]
#   [16 17 18 19]
#   [12 13 14 15]]]

print(np.flip(a_3d, 2))
# [[[ 3  2  1  0]
#   [ 7  6  5  4]
#   [11 10  9  8]]
# 
#  [[15 14 13 12]
#   [19 18 17 16]
#   [23 22 21 20]]]

print(a_3d[:, :, ::-1])
# [[[ 3  2  1  0]
#   [ 7  6  5  4]
#   [11 10  9  8]]
# 
#  [[15 14 13 12]
#   [19 18 17 16]
#   [23 22 21 20]]]

print(np.flip(a_3d, (0, 1)))
# [[[20 21 22 23]
#   [16 17 18 19]
#   [12 13 14 15]]
# 
#  [[ 8  9 10 11]
#   [ 4  5  6  7]
#   [ 0  1  2  3]]]

print(a_3d[::-1, ::-1])
# [[[20 21 22 23]
#   [16 17 18 19]
#   [12 13 14 15]]
# 
#  [[ 8  9 10 11]
#   [ 4  5  6  7]
#   [ 0  1  2  3]]]

print(np.flip(a_3d, (1, 2)))
# [[[11 10  9  8]
#   [ 7  6  5  4]
#   [ 3  2  1  0]]
# 
#  [[23 22 21 20]
#   [19 18 17 16]
#   [15 14 13 12]]]

print(a_3d[:, ::-1, ::-1])
# [[[11 10  9  8]
#   [ 7  6  5  4]
#   [ 3  2  1  0]]
# 
#  [[23 22 21 20]
#   [19 18 17 16]
#   [15 14 13 12]]]

print(np.flip(a_3d, (0, 2)))
# [[[15 14 13 12]
#   [19 18 17 16]
#   [23 22 21 20]]
# 
#  [[ 3  2  1  0]
#   [ 7  6  5  4]
#   [11 10  9  8]]]

print(a_3d[::-1, :, ::-1])
# [[[15 14 13 12]
#   [19 18 17 16]
#   [23 22 21 20]]
# 
#  [[ 3  2  1  0]
#   [ 7  6  5  4]
#   [11 10  9  8]]]
