def _trim_batch(
        cls,
        batch: dict[str, torch.Tensor],
    ) -> tuple[list[int], list[dict[str, torch.Tensor]]]:
        """Trims padding off all examples in batch.

        Args:
            batch (Dict[str, torch.Tensor]): Batch of padded data with tensors as values.

        Returns:
            A tuple with unpadded lengths of examples and a list of each trimmed example from the batch.
        """
        # Cut everything down to size
        sizes, trimmed_examples = [], []
        for idx in range(batch['attention_mask'].shape[0]):
            size, trimmed_example = cls._extract_trim_batch_idx(
                batch,
                idx,
            )
            sizes.append(size)
            trimmed_examples.append(trimmed_example)
        return sizes, trimmed_examples
Trims padding off all examples in batch.

        Args:
            batch (Dict[str, torch.Tensor]): Batch of padded data with tensors as values.

        Returns:
            A tuple with unpadded lengths of examples and a list of each trimmed example from the batch.
        
llmfoundry/data/packing.py