Meta's image-processing pipelines may apply a sequence of transformations to a square pixel matrix. Implement a command executor that modifies the matrix in order and returns its final state.
Supported commands are:
rotate90: Rotate the square matrix 90 degrees clockwise in place by transposing it, swapping rows and columns, and then reversing every row.swap_rows i j: Swap rows i and j.swap_cols i j: Swap columns i and j across every row.reverse_row i: Reverse the values in row i.The command strings are guaranteed to be valid. Return the same matrix object after all commands are executed.
Given matrix, a non-empty n x n list of lists of integers, and commands, a list of command strings, return the transformed n x n matrix. Indices are zero-based. All operations must modify the supplied matrix rather than constructing a replacement matrix for the primary solution.
def execute_matrix_commands(matrix, commands):