(tensor: Optional[torch.Tensor])
| 177 | |
| 178 | |
| 179 | def _empty_like_tensor(tensor: Optional[torch.Tensor]) -> Optional[torch.Tensor]: |
| 180 | if tensor is None or isinstance(tensor, list): |
| 181 | return tensor |
| 182 | return tensor[..., :0, :].clone() |
| 183 | |
| 184 | |
| 185 | def _ensure_same_layout(cache: DynamicCache, other: DynamicCache) -> None: |