def _validate_states(self) -> None:
        """
        Validate that the user provided states is consistent with the
        registered buffer in the torch model, and add states to inputs
        """
        if len(self.states) > 0:
            for state in self.states:
                if state.name is None or state.name not in self.graph.buffers:
                    raise ValueError(
                        f"StateType named {state.name} not provided or "
                        "not found in the source torch model. "
                        "Please make sure the name in "
                        "'ct.StateType(name=..., wrapped_type=ct.TensorType(...))' "
                        f"match the 'named_buffers()' in the source torch model: {list(self.graph.buffers.keys())}"
                    )

                state_shape = tuple(state.shape.symbolic_shape)
                buffer_shape = tuple(self.graph.buffers[state.name].size())
                # If Core ML state has fixed shape, then we make sure it matches torch buffer shape
                # Note: Although dynamic-shape state does not make sense at runtime,
                #       for flexibility in graph manipulation, pymil allows symbolic-shape state
                if not any_symbolic(state_shape):
                    if state_shape != buffer_shape:
                        raise ValueError(
                            f"StateType shape {state_shape} must match the torch buffer shape {buffer_shape}."
                        )

            if self.opset_version is None or self.opset_version < _target.iOS18:
                raise ValueError(
                    "State model is supported only >= iOS18. "
                    "Please update the minimum_deployment_target to at least coremltools.target.iOS18"
                )
            self.inputs.extend(self.states)

        Validate that the user provided states is consistent with the
        registered buffer in the torch model, and add states to inputs
        
coremltools/converters/mil/frontend/torch/converter.py