code: def _find_path_with_prefix(path: Path, expected_suffix: str) -> Path:
      """Find a file that is prefixed with the given path.
  
      Parameters
      ----------
      path
          The path to be searched.
      expected_suffix
          The suffix of the file we want.
      """
      if path.exists():
          return path
  
      for p in path.parent.iterdir():
          if (
              p.name.startswith(path.name)
              and p.name == path.name + expected_suffix
          ):
              return p
  
      # Iter again to give a warning.
      for p in path.parent.iterdir():
          if p.name.startswith(path.name):
              # Try to find the serializer type that can load this file.
              guessed_serializer_type: Type[Serializer] | None = None
              for serializer in Serializer.__subclasses__():
                  if p.name == path.name + serializer.suffix:
                      guessed_serializer_type = serializer
              if guessed_serializer_type is not None:
                  _logger.warning(
                      "Found file %s, which could be loaded by %s, but suffix %s is expected.",
                      p,
                      guessed_serializer_type,
                      expected_suffix,
                  )
              else:
                  _logger.warning(
                      "Found file %s, which does not match any serializer registered. Suffix %s is expected.",
                      p,
                      expected_suffix,
                  )
  
      raise FileNotFoundError(
          f"No file found with prefix {path} and suffix {expected_suffix}."
      )
  
file_path: nni/nni/nas/utils/serializer.py
imports: from __future__ import annotations
  import logging
  from pathlib import Path
  from typing import Any, ClassVar, Type, cast
label_desc: Use image node_id 3 for calling a global function with example usage: _find_path_with_prefix(path, expected_suffix) and returns: path, p