code: def _expand_dims(x, input_shape, output_shape):
    
    verify_no_new_dims([output_shape], input_shape)
    if input_shape == output_shape or input_shape.ndims == 0:
      return x
    perm = [input_shape.dims.index(d) for d in output_shape.dims
            if d in input_shape.dims]
    x = tf.transpose(x, perm)
    for i, d in enumerate(output_shape.dims):
      if d not in input_shape.dims:
        x = tf.expand_dims(x, i)
    return x
docs: Expand dimensions and transpose if necessary.
  
    Args:
      x: a tf.Tensor
      input_shape: a Shape
      output_shape: a Shape whose dimensions are a superset of
        those in input_shape
  
    Returns:
      a tf.Tensor