(self, idx, mod: Module)
| 240 | return self._size |
| 241 | |
| 242 | def insert(self, idx, mod: Module): |
| 243 | assert isinstance(mod, Module) |
| 244 | L = len(self) |
| 245 | if idx < 0: |
| 246 | idx = L - idx |
| 247 | # clip idx to (0, L) |
| 248 | if idx > L: |
| 249 | idx = L |
| 250 | elif idx < 0: |
| 251 | idx = 0 |
| 252 | |
| 253 | for new_idx in range(L, idx, -1): |
| 254 | orig_idx = new_idx - 1 |
| 255 | key = self._ikey(new_idx) |
| 256 | setattr(self, key, self[orig_idx]) |
| 257 | |
| 258 | key = self._ikey(idx) |
| 259 | setattr(self, key, mod) |
| 260 | self._size += 1 |
| 261 | |
| 262 | def forward(self): |
| 263 | raise RuntimeError("ModuleList is not callable") |
no test coverage detected