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

Class OutputRecorder

src/transformers/utils/output_capturing.py:41–57  ·  view source on GitHub ↗

Configuration for recording outputs from a model via hooks. Attributes: target_class (Type): The class (e.g., nn.Module) to which the hook will be attached. index (Optional[int]): If the output is a tuple/list, optionally record only at a specific index. layer_name

Source from the content-addressed store, hash-verified

39@dataclass
40@requires(backends=("torch",))
41class OutputRecorder:
42 """
43 Configuration for recording outputs from a model via hooks.
44
45 Attributes:
46 target_class (Type): The class (e.g., nn.Module) to which the hook will be attached.
47 index (Optional[int]): If the output is a tuple/list, optionally record only at a specific index.
48 layer_name (Optional[str]): Name of the submodule to target (if needed), e.g., "transformer.layer.3.attn".
49 class_name (Optional[str]): Name of the class to which the hook will be attached. Could be the suffix of class name in some cases.
50 capture_initial_hidden_state (bool): Whether to prepend the first module's input as the initial hidden state.
51 """
52
53 target_class: type[nn.Module]
54 index: int = 0
55 layer_name: str | None = None
56 class_name: str | None = None
57 capture_initial_hidden_state: bool = True
58
59
60class CompileableContextVar:

Callers 15

TestModelClass · 0.90
DogePreTrainedModelClass · 0.85
DogePreTrainedModelClass · 0.85
HYV3PreTrainedModelClass · 0.85
HYV3PreTrainedModelClass · 0.85
InformerEncoderClass · 0.85
InformerDecoderClass · 0.85
InformerEncoderClass · 0.85
InformerDecoderClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected