code: def test_yaml_read_and_write(tmp_path):
      temp_dir = str(tmp_path)
      yaml_file = random_file("yaml")
      long_value = 1  # pylint: disable=undefined-variable
      data = {
          "a": random_int(),
          "B": random_int(),
          "text_value": "中文",
          "long_value": long_value,
          "int_value": 32,
          "text_value_2": "hi",
      }
      file_utils.write_yaml(temp_dir, yaml_file, data)
      read_data = file_utils.read_yaml(temp_dir, yaml_file)
      assert data == read_data
      yaml_path = os.path.join(temp_dir, yaml_file)
      with codecs.open(yaml_path, encoding="utf-8") as handle:
          contents = handle.read()
      assert "!!python" not in contents
      # Check that UTF-8 strings are written properly to the file (rather than as ASCII
      # representations of their byte sequences).
      assert "中文" in contents
  
      def edit_func(old_dict):
          old_dict["more_text"] = "西班牙语"
          return old_dict
  
      assert "more_text" not in file_utils.read_yaml(
          temp_dir, yaml_file
      )
      with safe_edit_yaml(temp_dir, yaml_file, edit_func):
          editted_dict = file_utils.read_yaml(temp_dir, yaml_file)
          assert "more_text" in editted_dict
          assert editted_dict["more_text"] == "西班牙语"
      assert "more_text" not in file_utils.read_yaml(
          temp_dir, yaml_file
      )
  
imports: import codecs
  import filecmp
  import hashlib
  import json
  import os
  import shutil
  import stat
  import tarfile
  import jinja2.exceptions
  import pandas
  import pytest
  from pyspark.sql import SparkSession
  import mlflow
  from mlflow.exceptions import MissingConfigException
  from mlflow.utils import file_utils
  from mlflow.utils.file_utils import TempDir, _copy_file_or_tree, _handle_readonly_on_windows, get_parent_dir, get_total_file_size, local_file_uri_to_path, read_parquet_as_pandas_df, write_pandas_df_as_parquet, write_spark_dataframe_to_parquet_on_local_disk
  from mlflow.utils.os import is_windows
  from tests.helper_functions import random_file, random_int, safe_edit_yaml
  from tests.projects.utils import TEST_PROJECT_DIR
label_desc: Use image node_id 2 for calling a global function with example usage: test_yaml_read_and_write(tmp_path) and returns: old_dict