docstr: Args:
  Returns: denom, l_choice, r_choice
docstr_tok: ["Args",":","Returns",":","denom",",","l_choice",",","r_choice"]
code: def get_logits_inference(
      self,
      current_hidden_state,  # inference: (beam_size, 1, repr_dim)
      decoder_input_ids,  # (beam_size, seq_len, )
      full_hidden_states=None,  # tuple((beam_size, 1, repr_dim))
  ):
      """
      Args:
      Returns: denom, l_choice, r_choice
      """
      # Shape: (batch_size, seq_len, )
      batch_size = decoder_input_ids.size(0)
      output_ids = decoder_input_ids[:, 1:]  # excluding decoder BOS
  
      range_vec = (
          torch.arange(
              output_ids.size(1) - 1,
              -1,
              -1,
              dtype=torch.long,
              device=self.device,
          )
          .unsqueeze(0)
          .expand(batch_size, -1)
      )
  
      if len(full_hidden_states) == 0:
          # the first valid token in the output
          return (
              current_hidden_state.new_full(
                  (batch_size, 1, 1), float("-inf")
              ),
              decoder_input_ids.new_full((batch_size, 1), -1),
              decoder_input_ids.new_full((batch_size, 1), -1),
          )
  
      # concatenating into sequence: (beam_size, seq_len, repr_dim)
      decoder_output = torch.cat(full_hidden_states, dim=1)
      # check special tokens
      # Shape: (batch_size, seq_len, )
      is_l = output_ids == self.mention_start_id
      is_r = output_ids == self.mention_end_id
  
      if is_l.sum() == 0:
          # no full mention and no previous mentions
          lr_denom = current_hidden_state.new_full(
              (batch_size, 1, 1), float("-inf")
          )
          r_choice = decoder_input_ids.new_full((batch_size, 1), -1)
          l_choice = decoder_input_ids.new_full((batch_size, 1), -1)
          denom = lr_denom
      else:
          # (batch_size, num_l, dim), (batch_size, num_l, )
          l_emb, l_emb_mask = batched_masked_select(
              decoder_output, is_l
          )
  
          # (batch_size, 1, num_l, 2*dim)
          lr_pair_emb = prepare_pair_embeddings(
              l_emb, current_hidden_state
          )
          # (batch_size, 1, num_l)
          lr_score = self.lr_scorer(lr_pair_emb).squeeze(-1)
          num_l_each_instance = is_l.sum(dim=-1)
          for i in range(batch_size):
              if num_l_each_instance[i] - 20 > 0:
                  lr_score[i, :, : num_l_each_instance[i] - 20] = NEGINF
              lr_score[i, :, num_l_each_instance[i] :] = NEGINF
  
          # (batch_size, 1, 1)
          lr_denom = logsumexp(lr_score, dim=2, keepdim=True)
          # (batch_size, 1)
          l_choice = lr_score.max(dim=2)[1]
          r_choice = decoder_input_ids.new_full((batch_size, 1), -1)
  
          denom = lr_denom
          if is_r.sum() > 0:
              # (batch_size, num_r, dim), (batch_size, num_r, )
              r_emb, r_emb_mask = batched_masked_select(
                  decoder_output, is_r
              )
  
              # (batch_size, 1, num_r)
              distance_to_previous_r, _ = batched_masked_select(
                  range_vec, is_r
              )
              distance_to_previous_r = distance_to_previous_r.unsqueeze(
                  1
              )
  
              # (batch_size, 1, num_r, dim)
              rr_pair_emb = prepare_pair_embeddings(
                  r_emb, current_hidden_state
              )
              # (batch_size, 1, num_r, dim)
              r_distance_emb = self.emb_rr_distance(
                  util.relative_position_bucket(
                      -distance_to_previous_r,
                      bidirectional=False,
                      num_buckets=self.linking_distance_num_buckets,
                  )
              )
              rr_pair_emb = torch.cat(
                  [rr_pair_emb, r_distance_emb], dim=-1
              )
              # (batch_size, 1, num_r)
              rr_score = self.rr_scorer(rr_pair_emb).squeeze(-1)
              # (batch_size, 1, num_r)
              rr_score += (~r_emb_mask * NEGINF).unsqueeze(1)
              # (batch_size, 1, 1+num_r)
              rr_score = dummy_padding(rr_score)
              # (batch_size, 1)
              r_choice = rr_score.argmax(dim=-1) - 1
  
      return denom, l_choice, r_choice
  
imports: import sys
  import os
  from typing import Optional, Tuple, Any, Dict, Iterable
  import logging
  import torch
  import torch.utils.checkpoint
  from torch import nn
  import torch.nn.init
  import torch.nn.functional
  from transformers.models.t5.modeling_t5 import T5PreTrainedModel, T5Model, T5_INPUTS_DOCSTRING, _CONFIG_FOR_DOC
  from transformers.file_utils import add_start_docstrings_to_model_forward, replace_return_docstrings
  from .modeling_outputs import MySeq2SeqLMOutput
  from util import logsumexp, dummy_padding, prepare_pair_embeddings, one_hot_ignore_negative, batched_masked_select
label_desc: Use image node_id 3 for calling the T5Coref obj's underlying member method code with example usage: obj.get_logits_inference(current_hidden_state, decoder_input_ids, full_hidden_states) and returns: denom,  l_choice,  r_choice, current_hidden_state,  decoder_input_ids,  decoder_input_ids