Complete worked example
python
from bootstrap_lab import torch_setup
torch = torch_setup()
def copied_change(values):
source = torch.tensor(values, dtype=torch.float32)
copy = source.clone()
if copy.numel():
copy[0] = 99
return {'source': source.tolist(), 'copy': copy.tolist()}- Reasoning
- The helper constructs a source tensor, clones it and changes only the clone’s first value. Returning both arrays makes the ownership boundary observable.