THArgCheck(THTensor_(isSize)(input,indexDims),2,"Index tensor must have the same size as input tensor.");
THLongStorage_free(indexDims);
// Assert same tensor sizes across input and output apart from specified dimension.
for(intd=0;d<THTensor_(nDimension)(output);d++){
if(d!=dim)THArgCheck(THTensor_(size)(output,d)==THTensor_(size)(input,d),3,"Input tensor must have same size as output tensor apart from the specified dimension");