code: def xgb_happy_fns(x_train, y_train, serve_settings):
      @serve.prepare
      def prepare_fn(model_dir):
          model_dir_path = pathlib.Path(model_dir)
          model = XGBClassifier()
          model.fit(x_train, y_train)
          model.save_model(model_dir + "/model.xgb")
  
          whl_path = model_dir_path.joinpath("whl")
          whl_path.mkdir(exist_ok=True)
  
          # TODO: remove when we launch
          shutil.copy(
              os.path.join(
                  SERVE_DIR,
                  "sagemaker-2.181.1.dev0-py2.py3-none-any.whl",
              ),
              whl_path,
          )
  
      @serve.load
      def load_fn(model_dir):
          model = XGBClassifier()
          model.load_model(model_dir + "/model.xgb")
          return model
  
      @serve.invoke(**serve_settings)
      def predict_fn(model, input):
          y_pred = model.predict(input)
          predictions = [round(value) for value in y_pred]
          return predictions
  
      return XgbHappyFns(prepare_fn, load_fn, predict_fn)
  
imports: from __future__ import absolute_import
  import os
  import shutil
  import pytest
  import pathlib
  import collections
  import platform
  from numpy import loadtxt
  from xgboost import XGBClassifier
  from sklearn.model_selection import train_test_split
  from sagemaker import serve, image_uris
  from tests.integ import DATA_DIR
  from tests.integ.timeout import timeout
label_desc: Use image node_id 4 for calling a global function with example usage: xgb_happy_fns(x_train, y_train, serve_settings) and returns: XgbHappyFns, model, predictions