code: def _generate_valid_shape_pattern(
      inner_shape, inner_event_shape, reinterpreted_batch_ndims
  ):
      shape_pattern = []
      for bs, es, m in itertools.product(
          inner_shape, inner_event_shape, reinterpreted_batch_ndims
      ):
          if (m is not None) and (m > len(bs)):
              continue
          shape_pattern.append(
              {
                  "full_shape": bs + es,
                  "inner_shape": bs,
                  "inner_event_shape": es,
                  "reinterpreted_batch_ndims": m,
              }
          )
      return shape_pattern
  
imports: import functools
  import itertools
  import operator
  import numpy
  from chainer import distributions
  from chainer import testing
  from chainer.testing import array
  from chainer.testing import attr
  from chainer import utils
label_desc: Use image node_id 2 for calling a global function with example usage: _generate_valid_shape_pattern(inner_shape, inner_event_shape, reinterpreted_batch_ndims) and returns: shape_pattern