code: def xfun(n, d=None):
      
      if isinstance(n, six.integer_types):
          n = [n]
      if d is None:
          n0 = _np.asanyarray(n, dtype=_np.int32)
      else:
          n0 = _np.array(n * d, dtype=_np.int32)
      d = n0.size
      if d == 1:
          return _vector.vector.from_list(
              [_np.reshape(_np.arange(n0[0]), (1, n0[0], 1))])
      cr = []
      cur_core = _np.ones((1, n0[0], 2))
      cur_core[0, :, 0] = _np.arange(n0[0])
      cr.append(cur_core)
      ni = float(n0[0])
      for i in xrange(1, d - 1):
          cur_core = _np.zeros((2, n0[i], 2))
          for j in xrange(n0[i]):
              cur_core[:, j, :] = _np.eye(2)
          cur_core[1, :, 0] = ni * _np.arange(n0[i])
          ni *= n0[i]
          cr.append(cur_core)
      cur_core = _np.ones((2, n0[d - 1], 1))
      cur_core[1, :, 0] = ni * _np.arange(n0[d - 1])
      cr.append(cur_core)
      return _vector.vector.from_list(cr)
docs: Create a QTT-representation of 0:prod(n) _vector
          call examples:
          tt.xfun(2, 5)         # create 2 x 2 x 2 x 2 x 2 TT-vector
          tt.xfun(3)            # create [0, 1, 2] one-dimensional TT-vector
          tt.xfun([3, 5, 7], 2) # create 3 x 5 x 7 x 3 x 5 x 7 TT-vector