code: def _reorder_cache(self, past_key_values, beam_idx):
      # if decoder past is not included in output
      # speedy decoding is disabled and no need to reorder
      if past_key_values is None:
          logger.warning(
              "You might want to consider setting `use_cache=True` to speed up decoding"
          )
          return past_key_values
  
      reordered_decoder_past = ()
      for layer_past_states in past_key_values:
          # get the correct batch idx from layer past batch dim
          # batch dim of `past` is at 2nd position
          reordered_layer_past_states = ()
          for layer_past_state in layer_past_states:
              # need to set correct `past` for each of the four key / value states
              reordered_layer_past_states = (
                  reordered_layer_past_states
                  + (
                      layer_past_state.index_select(
                          0, beam_idx.to(layer_past_state.device)
                      ),
                  )
              )
  
          assert (
              reordered_layer_past_states[0].shape
              == layer_past_states[0].shape
          )
          assert len(reordered_layer_past_states) == len(
              layer_past_states
          )
  
          reordered_decoder_past = reordered_decoder_past + (
              reordered_layer_past_states,
          )
      return reordered_decoder_past
  
imports: import copy
  import math
  import warnings
  from typing import Optional, Tuple, Union
  from loguru import logger
  import torch
  import torch.distributed
  from torch import nn
  from torch.nn import CrossEntropyLoss
  from transformers.activations import ACT2FN
  from transformers.modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, Seq2SeqLMOutput
  from transformers.modeling_utils import PreTrainedModel
  from transformers.pytorch_utils import ALL_LAYERNORM_LAYERS
  from transformers.utils import is_torch_fx_proxy
  from transformers import T5Config
  from text_generation_server.utils.layers import TensorParallelColumnLinear, TensorParallelEmbedding, TensorParallelRowLinear, TensorParallelHead
label_desc: Use image node_id 5 for calling the T5ForConditionalGeneration obj's underlying member method code with example usage: obj._reorder_cache(past_key_values, beam_idx) and returns: reordered_decoder_past, past_key_values