Complete worked example
python
from bootstrap_lab import torch_setup
torch = torch_setup()
def describe(values):
tensor = torch.tensor(values, dtype=torch.float32, device='cpu')
if tensor.ndim != 2:
raise ValueError('matrix required')
return {'shape': list(tensor.shape), 'dtype': str(tensor.dtype),
'device': tensor.device.type, 'total': tensor.sum().item()}- Reasoning
- The helper constructs a float32 tensor on CPU from owned input values and requires exactly two dimensions. It reports observed shape, dtype, device and sum.