code: def make_batches(lines, args, task, max_positions):
      tokens = [
          task.source_dictionary.encode_line(
              src_str, add_if_not_exist=False
          ).long()
          for src_str in lines
      ]
      lengths = [t.numel() for t in tokens]
      itr = task.get_batch_iterator(
          dataset=task.build_dataset_for_inference(tokens, lengths),
          max_tokens=args.dataset.max_tokens,
          max_sentences=args.dataset.batch_size,
          max_positions=max_positions,
          ignore_invalid_inputs=args.dataset.skip_invalid_size_inputs_valid_test,
      ).next_epoch_itr(shuffle=False)
      for batch in itr:
          yield Batch(
              ids=batch["id"],
              src_tokens=batch["net_input"]["src_tokens"],
              src_lengths=batch["net_input"]["src_lengths"],
          )
  
file_path: fairseq/examples/textless_nlp/gslm/ulm/sample.py
imports: from collections import namedtuple
  import os
  import ast
  import numpy
  from fairseq import checkpoint_utils, options, tasks, utils
  import tqdm
label_desc: Use image node_id 1 for calling a global function with example usage: make_batches(lines, args, task, max_positions) without return types