code: def reverse_sequences(mini_batch, seq_lengths):
      reversed_mini_batch = torch.zeros_like(mini_batch)
      for b in range(mini_batch.size(0)):
          T = seq_lengths[b]
          time_slice = torch.arange(
              T - 1, -1, -1, device=mini_batch.device
          )
          reversed_sequence = torch.index_select(
              mini_batch[b, :, :], 0, time_slice
          )
          reversed_mini_batch[b, 0:T, :] = reversed_sequence
      return reversed_mini_batch
  
file_path: pyro/pyro/contrib/examples/polyphonic_data_loader.py
imports: import os
  import pickle
  from collections import namedtuple
  from urllib.request import urlopen
  import torch
  import torch.nn
  from torch.nn.utils.rnn import pad_sequence
  from pyro.contrib.examples.util import get_data_directory
label_desc: Use image node_id 3 for calling a global function with example usage: reverse_sequences(mini_batch, seq_lengths) and returns: reversed_mini_batch