currently, partial_trace does not explicitly validate:
that input_mat is square.
that np.prod(dim) equals the matrix dimension.
that sys indices are within valid subsystem bounds.
in some cases, invalid inputs lead to NumPy IndexError or unintended behavior rather than a clear ValueError.
i propose adding explicit validation checks along with corresponding unit tests for invalid inputs.