code: def augment_tensor(matrix, ndim=None):
      
      s = matrix.shape
      if ndim is None:
          ndim = s[0]+1
      arr = N.identity(ndim)
      arr[:s[0],:s[1]] = matrix
      return arr
docs: Increase the dimensionality of a tensor,
      splicing it into an identity matrix of a higher
      dimension. Useful for generalizing
      transformation matrices.