code: def get_parser(
      cls: Type["JAMLCompatible"], version: Optional[str]
  ) -> "VersionedYAMLParser":
      """
  
  
      .. # noqa: DAR401
      :param cls: the target class to parse
      :param version: yaml version number in "MAJOR[.MINOR]" format
      :return: parser given the YAML version
      """
      all_parsers, legacy_parser = _get_all_parser(cls)
      if version:
          if isinstance(version, (float, int)):
              version = str(version)
          for p in all_parsers:
              if p.version == version:
                  return p()
          for p in all_parsers:
              # fallback to major
              if version.split(".")[0] == p.version:
                  warnings.warn(
                      f"can not find parser for version: {version}, "
                      f"fallback to parser for version: {p.version}",
                      UserWarning,
                  )
                  return p()
          raise BadYAMLVersion(
              f"{version} is not a valid version number"
          )
      else:
          if version is not None:
              warnings.warn(
                  f"can not find parser for version: {version}, "
                  f"fallback to legacy parser. "
                  f"this usually mean you are using a deprecated YAML format.",
                  DeprecationWarning,
              )
          # fallback to legacy parser
          return legacy_parser()
  
file_path: jina/jina/jaml/parsers/__init__.py
imports: import warnings
  from typing import List, Optional, Type
  from jina.excepts import BadYAMLVersion
  from jina.jaml import JAMLCompatible
  from jina.jaml.parsers.base import VersionedYAMLParser
  from jina.orchestrate.deployments import Deployment
  from jina.serve.runtimes.gateway.gateway import BaseGateway
label_desc: Use image node_id 6 for calling a global function with example usage: get_parser(cls, version) and returns: legacy_parser, p, p