$L$ is a linear operator acting on hilbert space $V$ of dimension $n$, $L: V \to V$. The trace of a linear operator is defined as sum of diagonal entries of any matrix representation in same input and output basis of $V$. But if $L$ is a linear operator acting on $V \otimes V$ and I want to take partial tracepartial trace over the first/second system, it makes sense to me when the operator is expressed in dirac notation, eg a linear operator acting $ H \otimes H$ where $H$ is a 2-dimensional hilbert space in dirac notation is $$L_{AB} = |01\rangle \langle 00 | +|00\rangle \langle 10 | $$ $$tr_A(L_{AB})=|1\rangle \langle 0 |$$ $$tr_B(L_{AB})=|0\rangle \langle 1 |$$ here $\{|0\rangle , |1\rangle \}$ is an orthonormal basis for $H$. But how is the partial trace found and defined in terms of the matrix representation of the linear operator. Does the input and output basis have to be the same to define partial trace similar to definition of trace ?