getRow method
Implementation
Tensor getRow(int row) {
// 1. Safety check to prevent C++ segmentation faults
if (row < 0 || row >= shape[0]) throw RangeError("Row index out of bounds");
// 2. Call the engine. This returns a NEW C++ Tensor* with its own cudaMalloc'd memory.
final handle = engine.sliceTensor(_handle, row, 1);
// 3. We pass isView: false (default) because this handle is UNIQUE and
// must be destroyed to free the memory allocated by slice_tensor.
return Tensor._raw(handle, [1, shape[1]], isView: false);
}