get_dimension_variables#
- penzai.core.shapecheck.get_dimension_variables(structure: StructureAnnotation) DimensionVariableSubstitution[source]#
Returns a collection of all dimension variables in a structure.
- Parameters:
structure – The structure to extract variables from. Usually a PyTree with
ArraySpecleaves.- Returns:
A
DimensionVariableSubstitutionthat contains all dimension variables in the structure, mapping them back to themselves, so that callingfull_substitute_dimension_variableswould leave the result unchanged (except forKnownDiminstances). Usually, you will want to replace the values in the substitution with something else, and keep only the keys.