code: def _reorder_cache(past, beam_idx):
      reordered_past = ()
      for layer_past in past:
          reordered_past += (
              tuple(
                  past_state.index_select(0, beam_idx)
                  for past_state in layer_past
              ),
          )
      return reordered_past
  
imports: import copy
  import math
  import random
  from typing import Optional, Tuple
  import torch
  from torch import nn
  from torch.nn import CrossEntropyLoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_start_docstrings, logging, replace_return_docstrings
  from .configuration_trocr import TrOCRConfig
label_desc: Use image node_id 10 for calling the TrOCRForCausalLM obj's underlying member method code with example usage: obj._reorder_cache(past, beam_idx) and returns: reordered_past