class_docstr: Train a language model.
  
  Args:
      dictionary (~fairseq.data.Dictionary): the dictionary for the input of
          the language model
      output_dictionary (~fairseq.data.Dictionary): the dictionary for the
          output of the language model. In most cases it will be the same as
          *dictionary*, but could possibly be a more limited version of the
          dictionary (if ``--output-dictionary-size`` is used).
      targets (List[str]): list of the target types that the language model
          should predict.  Can be one of "self", "future", and "past".
          Defaults to "future".
  
  .. note::
  
      The language modeling task is compatible with :mod:`fairseq-train`,
      :mod:`fairseq-generate`, :mod:`fairseq-interactive` and
      :mod:`fairseq-eval-lm`.
  
  The language modeling task provides the following additional command-line
  arguments:
  
  .. argparse::
      :ref: fairseq.tasks.language_modeling_parser
      :prog:
class_docstr_tok: ["Train","a","language","model",".","Args",":","dictionary","(","~fairseq.data.Dictionary",")",":","the","dictionary","for","the","input","of","the","language","model","output_dictionary","(","~fairseq.data.Dictionary",")",":","the","dictionary","for","the","output","of","the","language","model",".","In","most","cases","it","will","be","the","same","as","*","dictionary","*",",","but","could","possibly","be","a","more","limited","version","of","the","dictionary","(","if","``","--","output-dictionary-size","``","is","used",")",".","targets","(","List","[","str","]",")",":","list","of","the","target","types","that","the","language","model","should","predict",".","Can","be","one","of","``","self","''",",","``","future","''",",","and","``","past","''",".","Defaults","to","``","future","''",".","..","note",":",":","The","language","modeling","task","is","compatible","with",":","mod",":","`","fairseq-train","`",",",":","mod",":","`","fairseq-generate","`",",",":","mod",":","`","fairseq-interactive","`","and",":","mod",":","`","fairseq-eval-lm","`",".","The","language","modeling","task","provides","the","following","additional","command-line","arguments",":","..","argparse",":",":",":","ref",":","fairseq.tasks.language_modeling_parser",":","prog",":"]
code: def inference_step(
      self,
      generator,
      models,
      sample,
      language="en_XX",
      prefix_tokens=None,
      constraints=None,
  ):
      # Generation will always be conditioned on bos_token
      if getattr(self.args, "add_bos_token", False):
          src_lang_idx = self.dictionary.index(lang_token(language))
          bos_token = src_lang_idx or self.source_dictionary.bos()
      else:
          bos_token = self.source_dictionary.eos()
  
      if constraints is not None:
          raise NotImplementedError(
              "Constrained decoding with the language_modeling task is not supported"
          )
  
      # SequenceGenerator doesn't use src_tokens directly, we need to
      # pass the `prefix_tokens` argument instead
      if (
          prefix_tokens is None
          and sample["net_input"]["src_tokens"].nelement()
      ):
          prefix_tokens = sample["net_input"]["src_tokens"]
          if prefix_tokens[:, 0].eq(bos_token).all():
              prefix_tokens = prefix_tokens[:, 1:]
  
      return generator.generate(
          models,
          sample,
          prefix_tokens=prefix_tokens,
          bos_token=bos_token,
      )
  
imports: import logging
  import os
  from dataclasses import dataclass, field
  from typing import Optional
  import numpy
  import torch
  from omegaconf import II
  from fairseq import utils
  from fairseq.data import AppendTokenDataset, ConcatDataset, Dictionary, IdDataset, LMContextWindowDataset, MonolingualDataset, NestedDictionaryDataset, NumelDataset, PadDataset, PrependTokenDataset, ResamplingDataset, SortDataset, 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
label_desc: Use image node_id 9 for calling the MultilingualLanguageModelingTask obj's underlying member method code with example usage: obj.inference_step(generator, models, sample, language, prefix_tokens, constraints) and returns: generator