code: def test_extract_score_and_justification():
      score1, justification1 = _extract_score_and_justification(
          '{"score": 4, "justification": "This is a justification"}'
      )
  
      assert score1 == 4
      assert justification1 == "This is a justification"
  
      score2, justification2 = _extract_score_and_justification(
          "score: 2 \njustification: This is a justification"
      )
  
      assert score2 == 2
      assert justification2 == "This is a justification"
  
      score3, justification3 = _extract_score_and_justification(
          properly_formatted_openai_response1
      )
      assert score3 == 3
      assert justification3 == (
          "The provided output mostly answers the question, but it is missing or hallucinating on "
          "some critical aspects.  Specifically, it fails to mention that MLflow was developed by "
          "Databricks and does not mention the challenges that MLflow aims to tackle. Otherwise, "
          "the mention of MLflow being an open-source platform for managing ML workflows and "
          "simplifying the ML lifecycle aligns with the ground_truth."
      )
  
      score4, justification4 = _extract_score_and_justification(
          '{"score": "4", "justification": "This is a justification"}'
      )
  
      assert score4 == 4
      assert justification4 == "This is a justification"
  
      score5, justification5 = _extract_score_and_justification(
          " Score: 2 \nJustification:\nThis is a justification"
      )
      assert score5 == 2
      assert justification5 == "This is a justification"
  
      malformed_output = '{"score": 4, "justification": {"foo": "bar"}}'
  
      score6, justification6 = _extract_score_and_justification(
          text=malformed_output
      )
  
      assert score6 is None
      assert (
          justification6
          == f"Failed to extract score and justification. Raw output: {malformed_output}"
      )
  
      score6, justification6 = _extract_score_and_justification(
          "Score: 2 \nJUSTIFICATION: This is a justification"
      )
  
      assert score6 == 2
      assert justification6 == "This is a justification"
  
imports: import inspect
  import re
  from unittest import mock
  import numpy
  import pandas
  import pytest
  from mlflow.exceptions import MlflowException
  from mlflow.metrics.genai import EvaluationExample, model_utils
  from mlflow.metrics.genai.genai_metric import _extract_score_and_justification, _format_args_string, make_genai_metric
  from mlflow.metrics.genai.metric_definitions import answer_correctness, answer_relevance, answer_similarity, faithfulness, relevance
  from mlflow.metrics.genai.prompts.v1 import AnswerCorrectnessMetric, AnswerRelevanceMetric, AnswerSimilarityMetric, FaithfulnessMetric, RelevanceMetric
label_desc: Use image node_id 9 for calling a global function with example usage: test_extract_score_and_justification() without return types