class_docstr: PyTorch Hub interface for generating sequences from a pre-trained
  translation or language model.
code: def __init__(self, cfg, task, models):
      super().__init__()
      self.cfg = cfg
      self.task = task
      self.models = nn.ModuleList(models)
      self.src_dict = task.source_dictionary
      self.tgt_dict = task.target_dictionary
  
      # optimize model for generation
      for model in self.models:
          model.prepare_for_inference_(cfg)
  
      # Load alignment dictionary for unknown word replacement
      # (None if no unknown word replacement, empty if no path to align dictionary)
      self.align_dict = utils.load_align_dict(
          cfg.generation.replace_unk
      )
  
      self.tokenizer = encoders.build_tokenizer(cfg.tokenizer)
      self.bpe = encoders.build_bpe(cfg.bpe)
  
      self.max_positions = utils.resolve_max_positions(
          self.task.max_positions(),
          *[model.max_positions() for model in models],
      )
  
      # this is useful for determining the device
      self.register_buffer(
          "_float_tensor", torch.tensor([0], dtype=torch.float)
      )
  
imports: import argparse
  import copy
  import logging
  import os
  from typing import Any, Dict, Iterator, List
  import torch
  from omegaconf import open_dict
  from torch import nn
  from fairseq import utils
  from fairseq.data import encoders
label_desc: Use image node_id 1 to create a new GeneratorHubInterface object from inherited base classes: nn with example: obj = GeneratorHubInterface(cfg, task, models)