Let $[k] = \{0,\dots,k-1\}$.
Consider the set $F(n,m)$ of functions $f:[n]\times[m]\rightarrow[m]$.
The cardinality of $F(n,m)$ is $|F(n,m)| = m^{nm}$.
Consider the equivalence relation $f \simeq g$ between functions $f,g \in F(n,m)$ iff
there are permutations $\pi:[n]\rightarrow [n]$ and $\tau:[m]\rightarrow [m]$ such that $\tau(f(n,m)) = g(\pi(n),\tau(m))$
(see Harary/Palmer: Enumeration of Finite Automata).
Harary/Palmer give an explicit formula to count the number $a(n,m)$ of orbits (equivalence classes) of $\simeq$. And they show that $a(2,2) = 7$ (compared to $|F(2,2)|=2^4=16$).
But I find it hard to get a number for $a(4,4)$ to be compared to $|F(4,4)| = 4^{16} \sim 4\cdot10^9 $, even given Harary/Palmer's formulas.
Is there a easy way to get this number?
[Add-on 2016-10-30]: Case n=4 added.
Hint: Observe the terms in the sum (1) do not make use of $\alpha$ but instead of $j_p(\alpha)$ only. So, it is not necessary to sum over all $\left(n!\right)^2$ pairs of permutations, as we can conveniently use the cycle index of the permutation group $S_n$ and considerably reduce the number of summands.
$$ $$
It it convenient to do some bookkeeping by use of tables. We list the permutations of $S_2=\{\operatorname{id},(12)\}$ in cycle notation and write a table with the number of cycles of each length for each permutation. We also write the corresponding monomial from the cycle index. \begin{array}{l|ccc} \pi&Z(S_2)&j_1(\pi)&j_2(\pi)\\ \hline \operatorname{id}& z_1^2& 2& 0\\ (12)& z_2^1& 0 &1\\ \end{array}
Comment:
The table is organised in blocks for pairs of permutation. Although here not eye-catching since we list all $\left(2!\right)^2=4$ pairs, we need in fact only for each cycle type one representative, since we are only interested in the length of cycles of a permutation. The column result gives the summands in (2). Here are the gory details:
Columns: $\alpha,\beta$ correspond to a pair of permutations $(\alpha,\beta)$ which is used as index in the outer sum of (2).
Columns: $p,q$ are the indices of the products in (2)
Column: $s$ gives the divisors of $\operatorname{lcm}(p,q)$
Columns: $j_s(\alpha),j_p(\alpha),j_q(\beta)$ list the cycle lengths
Column: $\text{factor}$ gives $$\left(\sum_{s|[p,q]}sj_s(\alpha)\right)^{j_p(\alpha)j_q(\beta)\langle p,q\rangle}$$
Column: $\text{result}$ calculates finally the product
$$\prod_{p=1}^2\prod_{q=1}^2 \left(\sum_{s|[p,q]}sj_s(\alpha)\right)^{j_p(\alpha)j_q(\beta)\langle p,q\rangle}$$
$$ $$
In order to calculate $a(3,3)$ we consider according to (1)
Note: The factors $1,3$ and $2$ in the column $Z(S_3)$ indicate the number of different permutations of the corresponding cycle type. We will use this fact to considerably reduce the calculation of the number of summands in (3).
In the following it is sufficient to calculate tables for the nine pairs \begin{align*} \{id,(12),(123)\}\times\{id,(12),(123)\} \end{align*} the cycle index provides the supplementary information we need to calculate the complete sum.
Note that in the main table above there is some redundancy to ease traceability. We now use a somewhat more compact notation to ease readability and keep the space small.
An example of a typical block is given here for $((12),(12))$ as it was done for all four blocks in the case $n=2$ and a summary table follows below.
$$ $$
$$ $$
In order to calculate $a(4,4)$ we consider according to (1)
Note: The factors $1,6,8,3$ and $6$ in the column $Z(S_4)$ indicate the number of different permutations of the corresponding cycle type. We will use this fact to considerably reduce the calculation of the number of summands in (4).
In the following it is sufficient to calculate tables for the $25$ pairs \begin{align*} \{id,(12),(123),(12)(34),(1234)\}\times\{id,(12),(123),(12)(34),(1234)\} \end{align*} the cycle index provides the supplementary information we need to calculate the complete sum.
Note that in the main table of $n=2$ above there is some redundancy to ease traceability. We now use analogously to $n=3$ above a somewhat more compact notation to ease readability and keep the space small.
$$ $$
Hint: Observe, that we only need to consider $25$ pairs of permutations instead of $\left(4!\right)^2=576$ pairs which are summed up in (4). We will consider all other permutations by respecting multiplicities given by the cycle-index $Z(S_4)$.
An example of a typical block is given here for $((123),(123))$ as it was done for all four blocks in the case $n=2$ and a summary table follows below.
$$ $$
Conclusion:
\begin{array}{c|rr} n&(n!)^2&\left(\text{via }Z(S_n)\right)^2\\ \hline 2&4&4\\ 3&36&9\\ 4&576&25\\ \end{array}