{"record":{"id":"03e737ccad75e024","repo":"huggingface/transformers","slug":"out-indices-must-be-a-list-got-type-self-out-in","errorCode":null,"errorMessage":"out_indices must be a list, got {type(self._out_indices)}","messagePattern":"out_indices must be a list, got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/backbone_utils.py","lineNumber":99,"sourceCode":"        if self._out_features is not None:\n            if not isinstance(self._out_features, (list,)):\n                raise ValueError(f\"out_features must be a list got {type(self._out_features)}\")\n            if any(feat not in self.stage_names for feat in self._out_features):\n                raise ValueError(\n                    f\"out_features must be a subset of stage_names: {self.stage_names} got {self._out_features}\"\n                )\n            if len(self._out_features) != len(set(self._out_features)):\n                raise ValueError(f\"out_features must not contain any duplicates, got {self._out_features}\")\n            if self._out_features != (\n                sorted_feats := [feat for feat in self.stage_names if feat in self._out_features]\n            ):\n                raise ValueError(\n                    f\"out_features must be in the same order as stage_names, expected {sorted_feats} got {self._out_features}\"\n                )\n\n        if self._out_indices is not None:\n            if not isinstance(self._out_indices, list):\n                raise ValueError(f\"out_indices must be a list, got {type(self._out_indices)}\")\n            # Convert negative indices to their positive equivalent: [-1,] -> [len(stage_names) - 1,]\n            positive_indices = tuple(idx % len(self.stage_names) if idx < 0 else idx for idx in self._out_indices)\n            if any(idx for idx in positive_indices if idx not in range(len(self.stage_names))):\n                raise ValueError(\n                    f\"out_indices must be valid indices for stage_names {self.stage_names}, got {self._out_indices}\"\n                )\n            if len(positive_indices) != len(set(positive_indices)):\n                msg = f\"out_indices must not contain any duplicates, got {self._out_indices}\"\n                msg += f\"(equivalent to {positive_indices}))\" if positive_indices != self._out_indices else \"\"\n                raise ValueError(msg)\n            if positive_indices != tuple(sorted(positive_indices)):\n                sorted_negative = [\n                    idx for _, idx in sorted(zip(positive_indices, self._out_indices), key=lambda x: x[0])\n                ]\n                raise ValueError(\n                    f\"out_indices must be in the same order as stage_names, expected {sorted_negative} got {self._out_indices}\"\n                )\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/backbone_utils.py#L81-L117","documentation":"Thrown by BackboneConfigMixin.verify_out_features_out_indices (via _out_indices validation) when the config's out_indices attribute is not a Python list. The library requires out_indices to be a plain list because subsequent validation iterates it, computes set() for duplicates, and zips it against out_features — all list assumptions. Typical cause is passing a tuple, numpy array, or int.","triggerScenarios":"Setting out_indices as a tuple (out_indices=(1, 2)), numpy array (out_indices=np.array([1,2])), a single int (out_indices=3), or None-like scalars in a backbone config (e.g. TimmBackboneConfig or any *BackboneConfiguration), then instantiating the model or calling config.verify_out_features_out_indices().","commonSituations":"Users copy out_indices from a timm config or a JSON checkpoint where it was serialized as a tuple; users coming from other APIs that accept tuples; programmatic config building that reuses numpy index arrays.","solutions":["Pass out_indices as a plain Python list: out_indices=[1, 2]","Convert before assigning: config.out_indices = list(your_indices)","If loading from a checkpoint/dict, coerce: out_indices = list(raw.get('out_indices', []))"],"exampleFix":"# before\nconfig.out_indices = (1, 2)  # tuple -> ValueError\n\n# after\nconfig.out_indices = [1, 2]  # list","handlingStrategy":"validation","validationCode":"if not isinstance(out_indices, list):\n    out_indices = list(out_indices)\nassert isinstance(out_indices, list), \"out_indices must be a list\"","typeGuard":"def is_valid_out_indices(v) -> bool:\n    return isinstance(v, list) and all(isinstance(i, int) for i in v)","tryCatchPattern":"try:\n    config.verify_out_features_out_indices()\nexcept ValueError as e:\n    raise ValueError(f\"Invalid backbone output config: {e}\") from e","preventionTips":["Always construct out_indices as a plain Python list literal","Coerce values deserialized from JSON/checkpoints with list(...)","Run config.verify_out_features_out_indices() early in your setup to fail fast"],"tags":["config","backbone","validation","type-error"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}