docstr: Saving and loading model files from paths.
docstr_tok: ["Saving","and","loading","model","files","from","paths","."]
code: def test_with_pathlib(self) -> None:
      """Saving and loading model files from paths."""
      save_path = Path("model.ubj")
  
      rng = np.random.default_rng(1994)
  
      data = rng.normal(size=(100, 2))
      target = np.array([0, 1] * 50)
      features = ["Feature1", "Feature2"]
  
      dm = xgb.DMatrix(data, label=target, feature_names=features)
      params = {
          "objective": "binary:logistic",
          "eval_metric": "logloss",
          "eta": 0.3,
          "max_depth": 1,
      }
  
      bst = xgb.train(params, dm, num_boost_round=1)
  
      # save, assert exists
      bst.save_model(save_path)
      assert save_path.exists()
  
      def dump_assertions(dump: List[str]) -> None:
          """Assertions for the expected dump from Booster"""
          assert len(dump) == 1, "Exepcted only 1 tree to be dumped."
          assert (
              len(dump[0].splitlines()) == 3
          ), "Expected 1 root and 2 leaves - 3 lines."
  
      # load the model again using Path
      bst2 = xgb.Booster(model_file=save_path)
      dump2 = bst2.get_dump()
      dump_assertions(dump2)
  
      # load again using load_model
      bst3 = xgb.Booster()
      bst3.load_model(save_path)
      dump3 = bst3.get_dump()
      dump_assertions(dump3)
  
      # remove file
      Path.unlink(save_path)
  
imports: import json
  import locale
  import os
  import pickle
  import tempfile
  from pathlib import Path
  from typing import List
  import numpy
  import pytest
  import xgboost
  from xgboost import testing
label_desc: Use image node_id 6 for calling the TestBoosterIO obj's underlying member method code with example usage: obj.test_with_pathlib() without return types