Since this is a private function, this is probably an acceptable place to put it. But I think ideally we'd put it somewhere like theano.tensor.basic and have it be public.