batch = (l.strip() for l in islice(f, batch_size*args_count))
if args_count > 1:
batch = zip(*[batch]*args_count)
batch = list(batch)
if not batch:
break
for res in model(batch):
if type(res).__module__ == "numpy":
res = res.tolist()
if not isinstance(res, str):
res = json.dumps(res, ensure_ascii=False)
print(res, flush=True)
if f is not sys.stdin:
f.close()