You need to optimise a given Python code, which takes a  3x3 matrix as input and outputs the inverse.
import numpy as np

def inverse_matrix(matrix):
    return np.linalg.inv(matrix)
import numpy as np

def inverse_matrix(matrix):
    det = np.linalg.det(matrix)
    if det == 0:
        return None 
    return np.dot(np.linalg.inv(matrix), 1/det)