code: def main(args):
      assert args.path is not None, "--path required for generation!"
      assert (
          not args.sampling or args.nbest == args.beam
      ), "--sampling requires --nbest to be equal to --beam"
      assert (
          args.replace_unk is None or args.dataset_impl == "raw"
      ), "--replace-unk requires a raw text dataset (--dataset-impl=raw)"
  
      if args.results_path is not None:
          os.makedirs(args.results_path, exist_ok=True)
          output_path = os.path.join(
              args.results_path,
              "generate-{}.txt".format(args.gen_subset),
          )
          with open(
              output_path, "w", buffering=1, encoding="utf-8"
          ) as h:
              return _main(args, h)
      else:
          return _main(args, sys.stdout)
  
file_path: lightseq/lightseq/training/cli/lightseq_infer_cli.py
imports: import ast
  import logging
  import math
  import os
  import sys
  from itertools import chain
  import pathlib
  import numpy
  import torch
  from fairseq import checkpoint_utils, options, scoring, tasks, utils
  from fairseq.logging import progress_bar
  from fairseq.logging.meters import StopwatchMeter, TimeMeter
  import lightseq.inference
label_desc: Use image node_id 1 for calling a global function with example usage: main(args) and returns: _main, _main