class_docstr: Inference model implementation for ragged batching for OPT models.
class_docstr_tok: ["Inference","model","implementation","for","ragged","batching","for","OPT","models","."]
code: def _forward_unembed(
      self,
      hidden_states: torch.Tensor,
      ragged_batch_info: RaggedBatchWrapper,
  ) -> torch.Tensor:
      logits = self.unembed(
          hidden_states,
          self._non_transformer.word_unembed,
          ragged_batch_info,
          gamma=self._non_transformer.final_norm_w,
          beta=self._non_transformer.final_norm_b,
      )
  
      if self.tp_size > 1:
          comm_buffer = empty_from(
              self._comm_logits,
              (self.tp_size, logits.shape[0], logits.shape[1]),
          )
          full_logits = empty_from(
              self._return_logits, (logits.shape[0], self.vocab_size)
          )
  
          dist.all_gather_into_tensor(
              comm_buffer, logits, group=self._base_mp_group
          )
  
          full_logits.copy_(
              comm_buffer.permute(1, 0, 2).reshape(
                  logits.shape[0], self.vocab_size
              )
          )
  
          return full_logits
      else:
          return logits
  
imports: from typing import Iterable, Optional, Tuple
  import torch
  import deepspeed.comm
  from ...allocator import empty_from
  from ...inference_utils import ActivationType, DtypeEnum
  from ...model_implementations import *
  from ...modules.configs import *
  from ...ragged import RaggedBatchWrapper
  from .container import OPTNonTransformerContainer, OPTTransformerContainer
  from ...modules.heuristics import instantiate_embed
label_desc: Use image node_id 16 for calling the OPTInferenceModel obj's underlying member method code with example usage: obj._forward_unembed(hidden_states, ragged_batch_info) and returns: full_logits, logits