code: def __init__(self, model):
      task = model.pop("task")
      if task not in _PYFUNC_SUPPORTED_TASKS:
          raise mlflow.MlflowException.invalid_parameter_value(
              f"Unsupported task: {task}. Supported tasks: {_PYFUNC_SUPPORTED_TASKS}."
          )
      self.model = model
      self.task = task
      self.api_config = _get_api_config()
      self.api_token = _OAITokenHolder(self.api_config.api_type)
      # If the same parameter exists in self.model & self.api_config,
      # we use the parameter from self.model
      self.envs = {
          x: getattr(self.api_config, x)
          for x in [
              "api_base",
              "api_version",
              "api_type",
              "engine",
              "deployment_id",
          ]
          if getattr(self.api_config, x) is not None
          and x not in self.model
      }
      api_type = self.model.get("api_type") or self.envs.get("api_type")
      if api_type in ("azure", "azure_ad", "azuread"):
          deployment_id = self.model.get(
              "deployment_id"
          ) or self.envs.get("deployment_id")
          if self.model.get("engine") or self.envs.get("engine"):
              # Avoid using both parameters as they serve the same purpose
              # Invalid inputs:
              #   - Wrong engine + correct/wrong deployment_id
              #   - No engine + wrong deployment_id
              # Valid inputs:
              #   - Correct engine + correct/wrong deployment_id
              #   - No engine + correct deployment_id
              if deployment_id is not None:
                  _logger.warning(
                      "Both engine and deployment_id are set. "
                      "Using engine as it takes precedence."
                  )
          elif deployment_id is None:
              raise MlflowException(
                  "Either engine or deployment_id must be set for Azure OpenAI API",
              )
  
      if self.task != "embeddings":
          self._setup_completions()
  
imports: import itertools
  import logging
  import os
  import warnings
  from string import Formatter
  from typing import Any, Dict, Optional, Set
  import yaml
  import mlflow
  from mlflow import pyfunc
  from mlflow.environment_variables import _MLFLOW_TESTING, MLFLOW_OPENAI_SECRET_SCOPE
  from mlflow.exceptions import MlflowException
  from mlflow.models import Model, ModelInputExample, ModelSignature
  from mlflow.models.model import MLMODEL_FILE_NAME
  from mlflow.models.utils import _save_example
  from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
  from mlflow.tracking._model_registry import DEFAULT_AWAIT_MAX_SLEEP_SECONDS
  from mlflow.tracking.artifact_utils import _download_artifact_from_uri
  from mlflow.types import ColSpec, Schema, TensorSpec
  from mlflow.utils.annotations import experimental
  from mlflow.utils.databricks_utils import check_databricks_secret_scope_access, is_in_databricks_runtime
  from mlflow.utils.docstring_utils import LOG_MODEL_PARAM_DOCS, format_docstring
  from mlflow.utils.environment import _CONDA_ENV_FILE_NAME, _CONSTRAINTS_FILE_NAME, _PYTHON_ENV_FILE_NAME, _REQUIREMENTS_FILE_NAME, _mlflow_conda_env, _process_conda_env, _process_pip_requirements, _PythonEnv, _validate_env_arguments
  from mlflow.utils.file_utils import write_to
  from mlflow.utils.model_utils import _add_code_from_conf_to_system_path, _get_flavor_configuration, _validate_and_copy_code_paths, _validate_and_prepare_target_save_path
  from mlflow.utils.openai_utils import REQUEST_URL_CHAT, REQUEST_URL_COMPLETIONS, REQUEST_URL_EMBEDDINGS, _OAITokenHolder, _OpenAIApiConfig, _OpenAIEnvVar, _validate_model_params
  from mlflow.utils.requirements_utils import _get_pinned_requirement
label_desc: Use image node_id 1 to create a new _OpenAIWrapper object  with example: obj = _OpenAIWrapper(model)