code: def to_multidimensional(tpm):
      
      # Cast to np.array.
      tpm = np.array(tpm)
      # Get the number of nodes.
      N = tpm.shape[-1]
      # Reshape. We use Fortran ordering here so that the rows use the
      # little-endian convention (least-significant bits correspond to low-index
      # nodes). Note that this does not change the actual memory layout (C- or
      # Fortran-contiguous), so there is no performance loss.
      return tpm.reshape([2] * N + [N], order="F").astype(float)
docs: Reshape a state-by-node TPM to the multidimensional form.
  
      See documentation for the |Network| object for more information on TPM
      formats.