| 436 | |
| 437 | |
| 438 | def make_composite_from_td(td): |
| 439 | # custom function to convert a ``tensordict`` in a similar spec structure |
| 440 | # of unbounded values. |
| 441 | composite = CompositeSpec( |
| 442 | { |
| 443 | key: make_composite_from_td(tensor) |
| 444 | if isinstance(tensor, TensorDictBase) |
| 445 | else UnboundedContinuousTensorSpec( |
| 446 | dtype=tensor.dtype, device=tensor.device, shape=tensor.shape |
| 447 | ) |
| 448 | for key, tensor in td.items() |
| 449 | }, |
| 450 | shape=td.shape, |
| 451 | ) |
| 452 | return composite |
| 453 | |
| 454 | |
| 455 | ###################################################################### |