how to apply numpy function on a tensor with unknown shape