code: def _reorder_cache(past, beam_idx):
      reordered_past = ()
      for layer_past in past:
          # cached cross_attention states don't have to be reordered -> they are always the same
          reordered_past += (
              tuple(
                  past_state.index_select(0, beam_idx)
                  for past_state in layer_past[:2]
              )
              + layer_past[2:],
          )
      return reordered_past
  
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 16 for calling the T5Coref obj's underlying member method code with example usage: obj._reorder_cache(past, beam_idx) and returns: reordered_past