Shortcuts

as_padded_tensor

class torchrl.envs.llm.transforms.as_padded_tensor(list_of_tensordicts: list[[<class 'tensordict.base.TensorDictBase'>]], dim=0, stack_dim: int = 0)[source]

Stacks a list of tensordicts into a single tensordict with padded tensors.

Parameters:
  • list_of_tensordicts (list[[TensorDictBase]]) – A list of tensordicts to stack.

  • dim (int, optional) – The dimension along which to pad. Defaults to 0.

  • stack_dim (int, optional) – The dimension along which to stack. Defaults to 0.

Returns:

A tensordict with padded tensors.

Return type:

TensorDictBase

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources