code: def flatten(seq: Sequence) -> Sequence:
      """
      Utility function to flatten any sequence ie [1, [2, 3], [4, [5, 6]]] -> [1, 2, 3, 4, 5, 6]
  
      Args:
          seq: The sequence to flatten
  
      Returns:
          The flattened out sequence
      """
  
      def _flatten(seq, a):
          for i in seq:
              if isinstance(i, Sequence) and not isinstance(
                  i, PackedSequence
              ):
                  _flatten(i, a)
              else:
                  a.append(i)
          return a
  
      return _flatten(seq, [])
  
file_path: opacus/opacus/tests/dp_layers/common.py
imports: import io
  import unittest
  from typing import Callable, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.utils.rnn import PackedSequence, pad_packed_sequence
  from torch.testing import assert_close
label_desc: Use image node_id 2 for calling a global function with example usage: flatten(seq) and returns: _flatten, a