LinkedList#
- class tensordict.utils.LinkedList(*args, td: TensorDictBase, **kwargs)#
Bases:
listA list of the values of a non-tensor entry that writes item assignments back to the tensordict.
td[key]returns aLinkedListwhen the entry is aNonTensorStack. Setting an item (values[0] = "z") writes the value to the tensordict.appendandextendchange the list only, and unlink it from the tensordict.Examples
>>> from tensordict import TensorDict >>> td = TensorDict(batch_size=[3]) >>> td["names"] = ["a", "b", "c"] >>> values = td["names"] >>> values[0] = "z" >>> td.get("names").tolist() ['z', 'b', 'c']