batchtensor
raw JSON → 0.1.1 verified Fri May 01 auth: no python
A Python library providing utility functions to manipulate batches of PyTorch tensors, such as concatenation, indexing, and nested data operations. Current version 0.1.1 supports Python 3.10-3.14 and PyTorch. The library follows a semantic versioning release cadence with regular updates.
pip install batchtensor Common errors
error ImportError: cannot import name 'nested_apply' from 'batchtensor' ↓
cause Incorrect import path: nested_apply is in batchtensor.nested subpackage.
fix
Use: from batchtensor.nested import nested_apply
error AttributeError: module 'batchtensor' has no attribute 'cat_along_batch' ↓
cause Attempting to import after a partial installation or using an older version that did not export cat_along_batch at top level.
fix
Install latest version: pip install --upgrade batchtensor
Warnings
breaking Version 0.0.4 introduced breaking changes (see release notes). Functions may have been renamed or arguments changed. ↓
fix Upgrade and update function calls per changelog.
gotcha batchtensor uses nested functions (e.g., nested_apply, nested_map) that expect nested structures of tensors. Passing plain tensors may raise unexpected errors. ↓
fix Ensure input is a dict or list of tensors, not a single tensor.
deprecated Some functions may be deprecated in future releases. Check the release notes before upgrading. ↓
fix Review deprecation warnings and migrate to recommended alternatives.
Imports
- cat_along_batch
from batchtensor import cat_along_batch - nested_apply wrong
from batchtensor import nested_applycorrectfrom batchtensor.nested import nested_apply
Quickstart
import torch
from batchtensor import cat_along_batch
tensor1 = torch.randn(2, 3)
tensor2 = torch.randn(3, 3)
result = cat_along_batch([tensor1, tensor2])
print(result.shape) # torch.Size([5, 3])