class_docstr: Task for the SpeechDLM model as described in the paper:
  https://arxiv.org/pdf/2203.16502.pdf
  
  It create a multi-channel dataset (SpeechDLMDataset) from multiple
  dictionaries.
  
  Args:
      dictionaries (Dict[str, ~fairseq.data.Dictionary]): the dictionaries for
          each input channel of the SpeechDLM model
      output_dictionaries (Dict[str, ~fairseq.data.Dictionary]): the dictionaries
          for the output of each channel of the SpeechDLM model. In most cases it
          will be the same as *dictionaries*.
      targets (List[str]): list of the target types that the SpeechDLM model
          should predict.  Can be one of "next", "edge", "duration".
          Defaults to "next".
  
  .. note::
  
      The SpeechDLM task is only compatible with
      :mod:`fairseq-train` and :mod:`fairseq-validate`.
      To generate new samples, please refer to example codes
      at examples/textless_nlp/dgslm .
class_docstr_tok: ["Task","for","the","SpeechDLM","model","as","described","in","the","paper",":","https",":","\/\/arxiv.org\/pdf\/2203.16502.pdf","It","create","a","multi-channel","dataset","(","SpeechDLMDataset",")","from","multiple","dictionaries",".","Args",":","dictionaries","(","Dict","[","str",",","~fairseq.data.Dictionary","]",")",":","the","dictionaries","for","each","input","channel","of","the","SpeechDLM","model","output_dictionaries","(","Dict","[","str",",","~fairseq.data.Dictionary","]",")",":","the","dictionaries","for","the","output","of","each","channel","of","the","SpeechDLM","model",".","In","most","cases","it","will","be","the","same","as","*","dictionaries","*",".","targets","(","List","[","str","]",")",":","list","of","the","target","types","that","the","SpeechDLM","model","should","predict",".","Can","be","one","of","``","next","''",",","``","edge","''",",","``","duration","''",".","Defaults","to","``","next","''",".","..","note",":",":","The","SpeechDLM","task","is","only","compatible","with",":","mod",":","`","fairseq-train","`","and",":","mod",":","`","fairseq-validate","`",".","To","generate","new","samples",",","please","refer","to","example","codes","at","examples\/textless_nlp\/dgslm","."]
code: def build_generator(self, models, args, extra_gen_cls_kwargs=None):
      from fairseq.models.speech_dlm.sequence_generator import (
          multichannel_search,
          MultichannelSequenceGenerator,
      )
  
      # Choose search strategy. Defaults to Beam Search.
      sampling = getattr(args, "sampling", False)
      sampling_topk = getattr(args, "sampling_topk", -1)
      sampling_topp = getattr(args, "sampling_topp", -1.0)
      assert (
          sampling_topk < 0 or sampling
      ), "--sampling-topk requires sampling (not beam search)"
      assert (
          sampling_topp < 0 or sampling
      ), "--sampling-topp requires sampling (not beam search)"
  
      if sampling:
          search_strategy = (
              multichannel_search.ContiguousMultichannelSampling(
                  self.target_dictionaries, sampling_topk, sampling_topp
              )
          )
      else:
          search_strategy = (
              multichannel_search.ContiguousMultichannelBeamSearch(
                  self.target_dictionaries
              )
          )
  
      extra_gen_cls_kwargs = extra_gen_cls_kwargs or {}
  
      return MultichannelSequenceGenerator(
          models,
          self.target_dictionaries,
          beam_size=getattr(args, "beam", 5),
          max_len_a=getattr(args, "max_len_a", 0),
          max_len_b=getattr(args, "max_len_b", 500),
          min_len=getattr(args, "min_len", 1),
          normalize_scores=(not getattr(args, "unnormalized", False)),
          len_penalty=getattr(args, "lenpen", 1),
          unk_penalty=getattr(args, "unkpen", 0),
          temperature=getattr(args, "temperature", 1.0),
          match_source_len=getattr(args, "match_source_len", False),
          no_repeat_ngram_size=getattr(args, "no_repeat_ngram_size", 0),
          search_strategy=search_strategy,
          duration_temperature=getattr(
              args, "duration_temperature", 1.0
          ),
          **extra_gen_cls_kwargs,
      )
  
imports: import logging
  import os
  from dataclasses import dataclass, field
  from typing import Optional
  from collections import OrderedDict
  import numpy
  import torch
  from fairseq import utils
  from fairseq.data import AppendTokenDataset, Dictionary, IdDataset, LMContextWindowDataset, MonolingualDataset, NestedDictionaryDataset, NumelDataset, PadDataset, PrependTokenDataset, SpeechDLMDataset, StripTokenDataset, TokenBlockDataset, TruncatedDictionary, data_utils
  from fairseq.data.indexed_dataset import get_available_dataset_impl
  from fairseq.data.shorten_dataset import maybe_shorten_dataset
  from fairseq.dataclass import ChoiceEnum, FairseqDataclass
  from fairseq.tasks import LegacyFairseqTask, register_task
  from omegaconf import II
label_desc: Use image node_id 13 for calling the SpeechDLMTask obj's underlying member method code with example usage: obj.build_generator(models, args, extra_gen_cls_kwargs) and returns: MultichannelSequenceGenerator