BUG: check if tensor is None before returning array without setting it