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 torch
  from transformers.models.bart.modeling_bart import BART_INPUTS_DOCSTRING, BART_START_DOCSTRING, BartConfig, BartModel, BartPretrainedModel, shift_tokens_right
  from transformers.utils import add_start_docstrings, add_start_docstrings_to_model_forward
  from ...heads import ClassificationHead, ModelWithFlexibleHeadsAdaptersMixin, MultiLabelClassificationHead, QuestionAnsweringHead, Seq2SeqLMHead
  from ...model_mixin import EmbeddingAdaptersWrapperMixin
  from ...wrappers import init
label_desc: Use image node_id 7 for calling the BartAdapterModel obj's underlying member method code with example usage: obj._reorder_cache(past, beam_idx) and returns: reordered_past