class_docstr: Base class for all RNN-like sequence models.
  
  DP-friendly drop-in replacement of the ``torch.nn.RNNBase`` module.
  After training this module can be exported and loaded by the original ``torch.nn``
  implementation for inference.
  
  This module implements multi-layer (Type-2, see
  [this issue](https://github.com/pytorch/pytorch/issues/4930#issuecomment-361851298))
  bi-directional sequential model based on abstract cell.
  Cell should be a subclass of ``DPRNNCellBase``.
  
  Limitations:
  - proj_size > 0 is not implemented
  - this implementation doesn't use cuDNN
class_docstr_tok: ["Base","class","for","all","RNN-like","sequence","models",".","DP-friendly","drop-in","replacement","of","the","``","torch.nn.RNNBase","``","module",".","After","training","this","module","can","be","exported","and","loaded","by","the","original","``","torch.nn","``","implementation","for","inference",".","This","module","implements","multi-layer","(","Type-2",",","see","[","this","issue","]","(","https",":","\/\/github.com\/pytorch\/pytorch\/issues\/4930","#","issuecomment-361851298",")",")","bi-directional","sequential","model","based","on","abstract","cell",".","Cell","should","be","a","subclass","of","``","DPRNNCellBase","``",".","Limitations",":","-","proj_size",">","0","is","not","implemented","-","this","implementation","does","n't","use","cuDNN"]
docstr: Iterate through all the layers and through all directions within each layer.
  
  Arguments should be list-like of length ``num_layers * num_directions`` where
  each element corresponds to (layer, direction) pair. The corresponding elements
  of each of these lists will be iterated over.
  
  Example:
      num_layers = 3
      bidirectional = True
  
      for layer, directions in self.iterate_layers(self.cell, h):
          for dir, (cell, hi) in directions:
              print(layer, dir, hi)
  
      # 0 0 h[0]
      # 0 1 h[1]
      # 1 0 h[2]
      # 1 1 h[3]
      # 2 0 h[4]
      # 2 1 h[5]
docstr_tok: ["Iterate","through","all","the","layers","and","through","all","directions","within","each","layer",".","Arguments","should","be","list-like","of","length","``","num_layers","*","num_directions","``","where","each","element","corresponds","to","(","layer",",","direction",")","pair",".","The","corresponding","elements","of","each","of","these","lists","will","be","iterated","over",".","Example",":","num_layers","=","3","bidirectional","=","True","for","layer",",","directions","in","self.iterate_layers","(","self.cell",",","h",")",":","for","dir",",","(","cell",",","hi",")","in","directions",":","print","(","layer",",","dir",",","hi",")","#","0","0","h","[","0","]","#","0","1","h","[","1","]","#","1","0","h","[","2","]","#","1","1","h","[","3","]","#","2","0","h","[","4","]","#","2","1","h","[","5","]"]
code: def iterate_layers(self, *args):
      """
      Iterate through all the layers and through all directions within each layer.
  
      Arguments should be list-like of length ``num_layers * num_directions`` where
      each element corresponds to (layer, direction) pair. The corresponding elements
      of each of these lists will be iterated over.
  
      Example:
          num_layers = 3
          bidirectional = True
  
          for layer, directions in self.iterate_layers(self.cell, h):
              for dir, (cell, hi) in directions:
                  print(layer, dir, hi)
  
          # 0 0 h[0]
          # 0 1 h[1]
          # 1 0 h[2]
          # 1 1 h[3]
          # 2 0 h[4]
          # 2 1 h[5]
  
      """
      for layer in range(self.num_layers):
          yield layer, (
              (
                  direction,
                  tuple(
                      arg[self.num_directions * layer + direction]
                      for arg in args
                  ),
              )
              for direction in range(self.num_directions)
          )
  
imports: import math
  import numbers
  import warnings
  from typing import List, Optional, Tuple, Type, Union
  import torch
  import torch.nn
  from torch import Tensor
  from torch.nn.utils.rnn import PackedSequence
  from ..utils.packed_sequences import compute_seq_lengths
  from .param_rename import RenameParamsMixin
label_desc: Use image node_id 4 for calling the DPRNNBase obj's underlying member method code with example usage: obj.iterate_layers() without return types