public static double beam_search(out string result, Intarray inputs, Floatarray costs, OcroFST fst1, OcroFST fst2,
int beam_width)
{
Intarray v1 = new Intarray();
Intarray v2 = new Intarray();
Intarray o = new Intarray();
//fprintf(stderr,"starting beam search\n");
beam_search(v1, v2, inputs, o, costs, fst1, fst2, beam_width);
//fprintf(stderr,"finished beam search\n");
FstUtil.remove_epsilons(out result, o);
return(NarrayUtil.Sum(costs));
}