Selects a range of samples. The result of this function is either a :class:`Batch` (if `sample_range` is a `slice` or a `list`) or a :class:`Tensor` if `sample_range` is a number.
(self, sample_range)
| 647 | return iter(self.tensors) |
| 648 | |
| 649 | def select(self, sample_range) -> "Batch | Tensor": |
| 650 | """ |
| 651 | Selects a range of samples. |
| 652 | |
| 653 | The result of this function is either a :class:`Batch` (if `sample_range` is a `slice` or a |
| 654 | `list`) or a :class:`Tensor` if `sample_range` is a number. |
| 655 | """ |
| 656 | r = sample_range |
| 657 | if r is ...: |
| 658 | return self |
| 659 | if isinstance(r, slice): |
| 660 | return Batch(self.tensors[r]) |
| 661 | elif isinstance(r, list): |
| 662 | return Batch(self.tensors[r]) |
| 663 | else: |
| 664 | return self._get_tensor(r) |
| 665 | |
| 666 | def _get_tensor(self, i) -> Tensor: |
| 667 | if self._tensors is None: |
no test coverage detected