def METHOD_NAME(cls, version: Union[bytes, str]) -> 'Version':
    """Convert string or bytes into Version object."""
    if isinstance(version, bytes):
        version = version.decode("UTF-8")
    match = cls._SEMVER_PATTERN.match(version)
    if match is None:
        raise ValueError(
            trans._(
                '{version} is not valid SemVer string',
                deferred=True,
                version=version,
            )
        )
    matched_version_parts: Dict[str, Any] = match.groupdict()
    return cls(**matched_version_parts)