func TensorStd(smat etensor.Tensor, a etensor.Tensor, met metric.StdMetrics) error {
	return Tensor(smat, a, metric.StdFunc64(met))
}
TensorStd computes a similarity / distance matrix on tensor
using given Std metric function.   Outer-most dimension ("rows") is
used as "indexical" dimension and all other dimensions within that
are compared.
Results go in smat which is ensured to have proper square 2D shape
(rows * rows).
This Std version is usable e.g., in Python where the func cannot be passed.
package simat
import (
	"fmt"
	"github.com/emer/etable/etensor"
	"github.com/emer/etable/metric"
)
func Tensor(smat etensor.Tensor, a etensor.Tensor, mfun metric.Func64) error {
	rows := a.Dim(0)
	nd := a.NumDims()
	if nd < 2 || rows == 0 {
		return fmt.Errorf("simat.Tensor: must have 2 or more dims and rows != 0")
	}
	ln := a.Len()
	sz := ln / rows
	sshp := []int{rows, rows}
	smat.SetShape(sshp, nil, nil)
	av := make([]float64, sz)
	bv := make([]float64, sz)
	ardim := []int{0}
	brdim := []int{0}
	sdim := []int{0, 0}
	for ai := 0; ai < rows; ai++ {
		ardim[0] = ai
		sdim[0] = ai
		ar := a.SubSpace(ardim)
		ar.Floats(&av)
		for bi := 0; bi <= ai; bi++ {  
			brdim[0] = bi
			sdim[1] = bi
			br := a.SubSpace(brdim)
			br.Floats(&bv)
			sv := mfun(av, bv)
			smat.SetFloat(sdim, sv)
		}
	}
	fdim := []int{0, 0}
	for ai := 0; ai < rows; ai++ {
		sdim[0] = ai
		fdim[1] = ai
		for bi := ai + 1; bi < rows; bi++ {  
			fdim[0] = bi
			sdim[1] = bi
			sv := smat.FloatVal(fdim)
			smat.SetFloat(sdim, sv)
		}
	}
	return nil
}
func Tensors(smat etensor.Tensor, a, b etensor.Tensor, mfun metric.Func64) error {
	arows := a.Dim(0)
	and := a.NumDims()
	brows := b.Dim(0)
	bnd := b.NumDims()
	if and < 2 || bnd < 2 || arows == 0 || brows == 0 {
		return fmt.Errorf("simat.Tensors: must have 2 or more dims and rows != 0")
	}
	alen := a.Len()
	asz := alen / arows
	blen := b.Len()
	bsz := blen / brows
	if asz != bsz {
		return fmt.Errorf("simat.Tensors: size of inner dimensions must be same")
	}
	sshp := []int{arows, brows}
	smat.SetShape(sshp, nil, []string{"a", "b"})
	av := make([]float64, asz)
	bv := make([]float64, bsz)
	ardim := []int{0}
	brdim := []int{0}
	sdim := []int{0, 0}
	for ai := 0; ai < arows; ai++ {
		ardim[0] = ai
		sdim[0] = ai
		ar := a.SubSpace(ardim)
		ar.Floats(&av)
		for bi := 0; bi < brows; bi++ {
			brdim[0] = bi
			sdim[1] = bi
			br := b.SubSpace(brdim)
			br.Floats(&bv)
			sv := mfun(av, bv)
			smat.SetFloat(sdim, sv)
		}
	}
	return nil
}