code: def test_parse_requirements(tmp_path, monkeypatch):
      """
      Ensures `_parse_requirements` returns the same result as `pip._internal.req.parse_requirements`
      """
      from pip._internal.network.session import PipSession
      from pip._internal.req import (
          parse_requirements as pip_parse_requirements,
      )
  
      root_req_src = """
  # No version specifier
  noverspec
  no-ver-spec
  
  # Version specifiers
  verspec<1.0
  ver-spec == 2.0
  
  # Environment marker
  env-marker; python_version < "3.8"
  
  inline-comm # Inline comment
  inlinecomm                        # Inline comment
  
  # Git URIs
  git+https://github.com/git/uri
  git+https://github.com/sub/dir#subdirectory=subdir
  
  # Requirements files
  -r {relative_req}
  --requirement {absolute_req}
  
  # Constraints files
  -c {relative_con}
  --constraint {absolute_con}
  
  # Line continuation
  line-cont\
  ==\
  1.0
  
  # Line continuation with spaces
  line-cont-space \
  == \
  1.0
  
  # Line continuation with a blank line
  line-cont-blank\
  
  # Line continuation at EOF
  line-cont-eof\
  """.strip()
  
      monkeypatch.chdir(tmp_path)
      root_req = tmp_path.joinpath("requirements.txt")
      # Requirements files
      rel_req = tmp_path.joinpath("relative_req.txt")
      abs_req = tmp_path.joinpath("absolute_req.txt")
      # Constraints files
      rel_con = tmp_path.joinpath("relative_con.txt")
      abs_con = tmp_path.joinpath("absolute_con.txt")
  
      # pip's requirements parser collapses an absolute requirements file path:
      # https://github.com/pypa/pip/issues/10121
      # As a workaround, use a relative path on Windows.
      absolute_req = abs_req.name if os.name == "nt" else str(abs_req)
      absolute_con = abs_con.name if os.name == "nt" else str(abs_con)
      root_req.write_text(
          root_req_src.format(
              relative_req=rel_req.name,
              absolute_req=absolute_req,
              relative_con=rel_con.name,
              absolute_con=absolute_con,
          )
      )
      rel_req.write_text("rel-req-xxx\nrel-req-yyy")
      abs_req.write_text("abs-req-zzz")
      rel_con.write_text("rel-con-xxx\nrel-con-yyy")
      abs_con.write_text("abs-con-zzz")
  
      expected_cons = [
          "rel-con-xxx",
          "rel-con-yyy",
          "abs-con-zzz",
      ]
  
      expected_reqs = [
          "noverspec",
          "no-ver-spec",
          "verspec<1.0",
          "ver-spec == 2.0",
          'env-marker; python_version < "3.8"',
          "inline-comm",
          "inlinecomm",
          "git+https://github.com/git/uri",
          "git+https://github.com/sub/dir#subdirectory=subdir",
          "rel-req-xxx",
          "rel-req-yyy",
          "abs-req-zzz",
          "line-cont==1.0",
          "line-cont-space == 1.0",
          "line-cont-blank",
          "line-cont-eof",
      ]
  
      parsed_reqs = list(
          _parse_requirements(root_req.name, is_constraint=False)
      )
      pip_reqs = list(
          pip_parse_requirements(root_req.name, session=PipSession())
      )
      # Requirements
      assert [
          r.req_str for r in parsed_reqs if not r.is_constraint
      ] == expected_reqs
      assert [
          r.requirement for r in pip_reqs if not r.constraint
      ] == expected_reqs
      # Constraints
      assert [
          r.req_str for r in parsed_reqs if r.is_constraint
      ] == expected_cons
      assert [
          r.requirement for r in pip_reqs if r.constraint
      ] == expected_cons
  
imports: import importlib
  import os
  import sys
  from unittest import mock
  import importlib_metadata
  import pytest
  import mlflow
  import mlflow.utils.requirements_utils
  from mlflow.utils.environment import infer_pip_requirements
  from mlflow.utils.requirements_utils import _capture_imported_modules, _get_installed_version, _get_pinned_requirement, _infer_requirements, _is_comment, _is_empty, _is_requirements_file, _join_continued_lines, _normalize_package_name, _parse_requirements, _prune_packages, _PyPIPackageIndex, _strip_inline_comment, _strip_local_version_label
label_desc: Use image node_id 6 for calling a global function with example usage: test_parse_requirements(tmp_path, monkeypatch) without return types