MCPcopy
hub / github.com/huggingface/transformers / _prepare_inputs

Method _prepare_inputs

src/transformers/trainer.py:2203–2215  ·  view source on GitHub ↗

Prepare `inputs` before feeding them to the model, converting them to tensors if they are not already and handling potential state.

(self, inputs: dict[str, torch.Tensor | Any])

Source from the content-addressed store, hash-verified

2201 return data
2202
2203 def _prepare_inputs(self, inputs: dict[str, torch.Tensor | Any]) -> dict[str, torch.Tensor | Any]:
2204 """
2205 Prepare `inputs` before feeding them to the model, converting them to tensors if they are not already and
2206 handling potential state.
2207 """
2208 inputs = self._prepare_input(inputs)
2209 if len(inputs) == 0:
2210 raise ValueError(
2211 "The batch received was empty, your model won't be able to train on it. Double-check that your "
2212 f"training dataset contains keys expected by the model: {','.join(self._signature_columns)}."
2213 )
2214
2215 return inputs
2216
2217 def _prepare_context_parallel_inputs(
2218 self, model: nn.Module, inputs: dict[str, torch.Tensor | Any]

Callers 3

training_stepMethod · 0.95
prediction_stepMethod · 0.95
prediction_stepMethod · 0.45

Calls 2

_prepare_inputMethod · 0.95
joinMethod · 0.80

Tested by

no test coverage detected