code: def _split_and_reshape_event(x, model):
      """Splits and reshapes a flat event `x` to match the structure of `model`."""
      splits = [
          ps.maximum(1, ps.reduce_prod(s))
          for s in tf.nest.flatten(model.event_shape)
      ]
      x = tf.nest.pack_sequence_as(
          model.event_shape, tf.split(x, splits, axis=-1)
      )
  
      def _reshape_part(part, dtype, event_shape):
          part = tf.cast(part, dtype)
          new_shape = ps.concat(
              [ps.shape(part)[:-1], event_shape], axis=-1
          )
          return tf.reshape(part, ps.cast(new_shape, tf.int32))
  
      x = tf.nest.map_structure(
          _reshape_part, x, model.dtype, model.event_shape
      )
      return x
  
file_path: probability/spinoffs/inference_gym/inference_gym/targets/vector_model.py
imports: import collections
  import functools
  import tensorflow.compat.v2
  import tensorflow_probability
  from tensorflow_probability.python.internal import prefer_static
  from inference_gym.targets import model
  from tensorflow.python.util import nest
label_desc: Use image node_id 5 for calling a global function with example usage: _split_and_reshape_event(x, model) and returns: x, tf