code: def _flatten(iterable: Iterable[T]) -> Generator[T, None, None]:
      iterator, sentinel, stack = iter(iterable), object(), []
      while True:
          value = next(iterator, sentinel)
          if value is sentinel:
              if not stack:
                  break
              iterator = stack.pop()
          else:
              try:
                  new_iterator = iter(value)
              except TypeError:
                  yield value
              else:
                  stack.append(iterator)
                  iterator = new_iterator
  
imports: import itertools
  import random
  import unittest
  from typing import Dict, Generator, Iterable, List, Optional, Tuple, TypeVar, Union
  import hypothesis.strategies
  import torch
  import torch.distributed
  from hypothesis import given, settings
  from torchrec.distributed.dist_data import _get_recat, KJTAllToAll, KJTAllToAllSplitsAwaitable, PooledEmbeddingsAllGather, PooledEmbeddingsAllToAll, PooledEmbeddingsReduceScatter, SequenceEmbeddingsAllToAll, VariableBatchPooledEmbeddingsAllToAll
  from torchrec.distributed.fbgemm_qcomm_codec import CommType, get_qcomm_codecs, QCommsConfig
  from torchrec.distributed.test_utils.multi_process import MultiProcessTestBase
  from torchrec.sparse.jagged_tensor import KeyedJaggedTensor
label_desc: Use image node_id 1 for calling a global function with example usage: _flatten(iterable) without return types