code: def generate(
      bart,
      infile,
      outfile="bart_hypo.txt",
      bsz=32,
      n_obs=None,
      **eval_kwargs,
  ):
      count = 1
  
      # if n_obs is not None: bsz = min(bsz, n_obs)
  
      with open(infile) as source, open(outfile, "w") as fout:
          sline = source.readline().strip()
          slines = [sline]
          for sline in source:
              if n_obs is not None and count > n_obs:
                  break
              if count % bsz == 0:
                  hypotheses_batch = bart.sample(slines, **eval_kwargs)
                  for hypothesis in hypotheses_batch:
                      fout.write(hypothesis + "\n")
                      fout.flush()
                  slines = []
  
              slines.append(sline.strip())
              count += 1
  
          if slines != []:
              hypotheses_batch = bart.sample(slines, **eval_kwargs)
              for hypothesis in hypotheses_batch:
                  fout.write(hypothesis + "\n")
                  fout.flush()
  
imports: import torch
  from fairseq.models.bart import BARTModel
  import argparse
label_desc: Use image node_id 1 for calling a global function with example usage: generate(bart, infile, outfile, bsz, n_obs) without return types