code: def _add_event_dims_to_mask(
      validity_mask, *, dist=None, event_ndims=None
  ):
      validity_mask = tf.convert_to_tensor(validity_mask)
      if event_ndims is None:
          event_ndims = ps.rank_from_shape(dist.event_shape_tensor())
      return tf.reshape(
          validity_mask,
          ps.concat(
              [
                  ps.shape(validity_mask),
                  ps.ones(event_ndims, dtype=tf.int32),
              ],
              axis=0,
          ),
      )
  
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  from tensorflow_probability.python.distributions import batch_broadcast
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions import log_prob_ratio
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import auto_composite_tensor
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensor_util
label_desc: Use image node_id 1 for calling a global function with example usage: _add_event_dims_to_mask(validity_mask) and returns: tf