Repeats tensor number of times along each dimension specified by `repeats`. `repeats` can be passed as a tuple or as separate arguments. ```python exec="true" source="above" session="tensor" result="python" t = Tensor([1, 2, 3]) print(t.repeat(4, 2).numpy()) ``` ```pyth
(self, repeats, *args)
| 545 | return x |
| 546 | |
| 547 | def repeat(self, repeats, *args) -> Self: |
| 548 | """ |
| 549 | Repeats tensor number of times along each dimension specified by `repeats`. |
| 550 | `repeats` can be passed as a tuple or as separate arguments. |
| 551 | |
| 552 | ```python exec="true" source="above" session="tensor" result="python" |
| 553 | t = Tensor([1, 2, 3]) |
| 554 | print(t.repeat(4, 2).numpy()) |
| 555 | ``` |
| 556 | ```python exec="true" source="above" session="tensor" result="python" |
| 557 | print(t.repeat(4, 2, 1).shape) |
| 558 | ``` |
| 559 | """ |
| 560 | repeats = argfix(repeats, *args) |
| 561 | base_shape = _align_left(self.shape, repeats)[0] |
| 562 | unsqueezed_shape = flatten([[s] if r == 1 else [1, s] for r, s in zip(repeats, base_shape)]) |
| 563 | expanded_shape = flatten([[s] if r == 1 else [r, s] for r, s in zip(repeats, base_shape)]) |
| 564 | final_shape = [r * s for r, s in zip(repeats, base_shape)] |
| 565 | return self.reshape(unsqueezed_shape).expand(expanded_shape).reshape(final_shape) |
| 566 | |
| 567 | # **** pool level **** |
| 568 |