code: def parse_config_source(
      path: Union[str, TextIO, Dict],
      allow_stream: bool = True,
      allow_yaml_file: bool = True,
      allow_raw_yaml_content: bool = True,
      allow_class_type: bool = True,
      allow_dict: bool = True,
      allow_json: bool = True,
      allow_url: bool = True,
      allow_py_module_class_type: bool = True,
      extra_search_paths: Optional[List[str]] = None,
      *args,
      **kwargs,
  ) -> Tuple[TextIO, Optional[str]]:
      """
      Check if the text or text stream is valid.
  
      .. # noqa: DAR401
      :param path: the multi-kind source of the configs.
      :param allow_stream: flag
      :param allow_yaml_file: flag
      :param allow_raw_yaml_content: flag
      :param allow_class_type: flag
      :param allow_py_module_class_type: flag
      :param allow_dict: flag
      :param allow_json: flag
      :param allow_url: flag
      :param extra_search_paths: extra paths to search for
      :param args: unused
      :param kwargs: unused
      :return: a tuple, the first element is the text stream, the second element is the file path associate to it
              if available.
      """
      import io
  
      if not path:
          raise BadConfigSource
      elif allow_dict and isinstance(path, dict):
          from jina.jaml import JAML
  
          tmp = JAML.dump(path)
          return io.StringIO(tmp), None
      elif allow_stream and hasattr(path, "read"):
          # already a readable stream
          return path, None
      elif allow_yaml_file and is_yaml_filepath(path):
          comp_path = complete_path(path, extra_search_paths)
          return open(comp_path, encoding="utf-8"), comp_path
      elif allow_url and urllib.parse.urlparse(path).scheme in {
          "http",
          "https",
      }:
          req = urllib.request.Request(
              path, headers={"User-Agent": "Mozilla/5.0"}
          )
          with urllib.request.urlopen(req) as fp:
              return io.StringIO(fp.read().decode("utf-8")), None
      elif allow_raw_yaml_content and path.lstrip().startswith(
          ("!", "jtype")
      ):
          # possible YAML content
          path = path.replace("|", "\n    with: ")
          return io.StringIO(path), None
      elif allow_class_type and path.isidentifier():
          # possible class name
          return io.StringIO(f"!{path}"), None
      elif (
          allow_py_module_class_type
          and "." in path
          and path.split(".")[-1].isidentifier()
      ):
          # possible module.class name
          module_name, cls_name = path.rsplit(".", maxsplit=1)
          PathImporter.add_modules(module_name)
          return io.StringIO(f"!{cls_name}"), None
      elif allow_json and isinstance(path, str):
          try:
              from jina.jaml import JAML
  
              tmp = json.loads(path)
              tmp = JAML.dump(tmp)
              return io.StringIO(tmp), None
          except json.JSONDecodeError:
              raise BadConfigSource(path)
      else:
          raise BadConfigSource(
              f"{path} can not be resolved, it should be a readable stream,"
              " or a valid file path, or a supported class name."
          )
  
imports: import collections
  import json
  import os
  import urllib.parse
  import urllib.request
  from typing import Any, Dict, List, Optional, TextIO, Tuple, Union
  from yaml import MappingNode
  from yaml.composer import Composer
  from yaml.constructor import ConstructorError, FullConstructor
  from yaml.parser import Parser
  from yaml.reader import Reader
  from yaml.resolver import Resolver
  from yaml.scanner import Scanner
  from jina.excepts import BadConfigSource
  from jina.helper import is_yaml_filepath
  from jina.importer import PathImporter
label_desc: Use image node_id 2 for calling a global function with example usage: parse_config_source(path, allow_stream, allow_yaml_file, allow_raw_yaml_content, allow_class_type, allow_dict, allow_json, allow_url, allow_py_module_class_type, extra_search_paths) and returns: io,  None, path,  None, open,  comp_path, io,  None, io,  None, io,  None, io,  None, io,  None