code: def _nd_indices_to_cover_each_2d(
      shape: tp.Sequence[int],
  ) -> tp.Iterator[tp.Tuple[int, ...]]:
      rs = numpy.random.RandomState(seed=0)
      n = len(shape)
      indices = [
          list(range(length)) for length in shape
      ]  # type: tp.List[tp.List[int]]  # NOQA
  
      # `(k_i, k_j) in uncovered[(i, j)]` iff it has not been yielded
      # `nd_index` such that `(nd_index[i], nd_inde[j]) == (k_i, k_j)`.
      uncovered = (
          {}
      )  # type: tp.Dict[tp.Tuple[int, int], tp.Set[tp.Tuple[int, int]]]  # NOQA
      for i, j in itertools.combinations(range(n), 2):
          uncovered[(i, j)] = set(
              itertools.product(indices[i], indices[j])
          )
  
      nd_indices = list(
          itertools.product(*indices)
      )  # type: tp.List[tp.Tuple[int, ...]]  # NOQA
      rs.shuffle(nd_indices)
      for nd_index in nd_indices:
          count = 0
          for i, j in itertools.combinations(range(n), 2):
              try:
                  uncovered[(i, j)].remove((nd_index[i], nd_index[j]))
              except KeyError:
                  pass
              else:
                  count += 1
          if count > 0:
              yield nd_index
  
imports: import functools
  import itertools
  import types
  import typing
  import unittest
  import numpy
  import six
  from chainer.testing import _bundle
  from chainer import utils
label_desc: Use image node_id 14 for calling a global function with example usage: _nd_indices_to_cover_each_2d(shape) without return types