refactor: Centralized implementation for GetElementCount and GetByteSize
#8723
+153
−62
GetElementCount and GetByteSize
#8723