code: def pack_sequences_recursive(sequences):
      """Pack sequences into PackedSequence recursively.
  
      This function works similarly to `torch.nn.utils.rnn.pack_sequence` except
      that it works recursively for tuples.
  
      When each given sequence is an N-tuple of `torch.Tensor`s, the function
      returns an N-tuple of `torch.nn.utils.rnn.PackedSequence`, packing i-th
      tensors separately for i=1,...,N.
  
      Args:
          sequences (object): Batch of sequences to pack.
  
      Returns:
          object: Packed sequences. If `sequences` is a list of tensors, then the
              returned value is a `PackedSequence`. If `sequences` is a list of
              tuples of tensors, then the returned value is a tuple of
              `PackedSequence`.
      """
      assert sequences
      first_seq = sequences[0]
      if isinstance(first_seq, torch.Tensor):
          return nn.utils.rnn.pack_sequence(sequences)
      if isinstance(first_seq, tuple):
          return tuple(
              pack_sequences_recursive([seq[i] for seq in sequences])
              for i in range(len(first_seq))
          )
      return sequences
  
file_path: pfrl/pfrl/utils/recurrent.py
imports: import itertools
  import numpy
  import torch
  from torch import nn
label_desc: Use image node_id 12 for calling a global function with example usage: pack_sequences_recursive(sequences) and returns: sequences, nn, tuple