code: def _reshape_to_matrix(basis_tensor, event_ndims):
      # Reshape basis so that there is only one ambient dimension.
      basis_tensor = ps.reshape(
          basis_tensor,
          ps.concat(
              [
                  ps.shape(basis_tensor)[
                      : ps.rank(basis_tensor) - event_ndims
                  ],
                  [-1],
              ],
              axis=0,
          ),
      )
      if event_ndims == 0:
          basis_tensor = basis_tensor[..., tf.newaxis]
      # Finally move the basis vector dimension to the end so we have shape [B1,
      # ..., Bk, N, D].
      return distribution_util.move_dimension(basis_tensor, 0, -2)
  
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import nest_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
label_desc: Use image node_id 6 for calling a global function with example usage: _reshape_to_matrix(basis_tensor, event_ndims) and returns: distribution_util