code: def sum(a, axis=-1):
      
      d = a.d
      crs = _vector.vector.to_list(a.tt if isinstance(a, _matrix.matrix) else a)
      if axis < 0:
          axis = range(a.d)
      elif isinstance(axis, int):
          axis = [axis]
      axis = list(axis)[::-1]
      for ax in axis:
          crs[ax] = _np.sum(crs[ax], axis=1)
          rleft, rright = crs[ax].shape
          if (rleft >= rright or rleft < rright and ax + 1 >= d) and ax > 0:
              crs[ax - 1] = _np.tensordot(crs[ax - 1], crs[ax], axes=(2, 0))
          elif ax + 1 < d:
              crs[ax + 1] = _np.tensordot(crs[ax], crs[ax + 1], axes=(1, 0))
          else:
              return _np.sum(crs[ax])
          crs.pop(ax)
          d -= 1
      return _vector.vector.from_list(crs)
docs: Sum TT-vector over specified axes