code: def log_model(
      model,
      task,
      artifact_path,
      conda_env=None,
      code_paths=None,
      registered_model_name=None,
      signature: ModelSignature = None,
      input_example: ModelInputExample = None,
      await_registration_for=DEFAULT_AWAIT_MAX_SLEEP_SECONDS,
      pip_requirements=None,
      extra_pip_requirements=None,
      metadata=None,
      example_no_conversion=False,
      **kwargs,
  ):
      """
      Log an OpenAI model as an MLflow artifact for the current run.
  
      Args:
          model: The OpenAI model name or reference instance, e.g.,
              ``openai.Model.retrieve("gpt-3.5-turbo")``.
          task: The task the model is performing, e.g., ``openai.ChatCompletion`` or
              ``'chat.completions'``.
          artifact_path: Run-relative artifact path.
          conda_env: {{ conda_env }}
          code_paths: A list of local filesystem paths to Python file dependencies (or directories
              containing file dependencies). These files are *prepended* to the system
              path when the model is loaded.
          registered_model_name: If given, create a model version under
              ``registered_model_name``, also creating a registered model if one
              with the given name does not exist.
          signature: :py:class:`ModelSignature <mlflow.models.ModelSignature>`
              describes model input and output :py:class:`Schema <mlflow.types.Schema>`.
              The model signature can be :py:func:`inferred <mlflow.models.infer_signature>`
              from datasets with valid model input (e.g. the training dataset with target
              column omitted) and valid model output (e.g. model predictions generated on
              the training dataset), for example:
  
              .. code-block:: python
  
                  from mlflow.models import infer_signature
  
                  train = df.drop_column("target_label")
                  predictions = ...  # compute model predictions
                  signature = infer_signature(train, predictions)
  
          input_example: {{ input_example }}
          await_registration_for: Number of seconds to wait for the model version to finish
              being created and is in ``READY`` status. By default, the function
              waits for five minutes. Specify 0 or None to skip waiting.
          pip_requirements: {{ pip_requirements }}
          extra_pip_requirements: {{ extra_pip_requirements }}
          metadata: Custom metadata dictionary passed to the model and stored in the MLmodel file.
  
              .. Note:: Experimental: This parameter may change or be removed in a future
                                      release without warning.
          example_no_conversion: {{ example_no_conversion }}
          kwargs: Keyword arguments specific to the OpenAI task, such as the ``messages`` (see
              :ref:`mlflow.openai.messages` for more details on this parameter)
              or ``top_p`` value to use for chat completion.
  
      Returns:
          A :py:class:`ModelInfo <mlflow.models.model.ModelInfo>` instance that contains the
          metadata of the logged model.
  
      .. code-block:: python
  
          import mlflow
          import openai
  
          # Chat
          with mlflow.start_run():
              info = mlflow.openai.log_model(
                  model="gpt-3.5-turbo",
                  task=openai.ChatCompletion,
                  messages=[{"role": "user", "content": "Tell me a joke about {animal}."}],
                  artifact_path="model",
              )
              model = mlflow.pyfunc.load_model(info.model_uri)
              df = pd.DataFrame({"animal": ["cats", "dogs"]})
              print(model.predict(df))
  
          # Embeddings
          with mlflow.start_run():
              info = mlflow.openai.log_model(
                  model="text-embedding-ada-002",
                  task=openai.Embedding,
                  artifact_path="embeddings",
              )
              model = mlflow.pyfunc.load_model(info.model_uri)
              print(model.predict(["hello", "world"]))
      """
  
      return Model.log(
          artifact_path=artifact_path,
          flavor=mlflow.openai,
          registered_model_name=registered_model_name,
          model=model,
          task=task,
          conda_env=conda_env,
          code_paths=code_paths,
          signature=signature,
          input_example=input_example,
          await_registration_for=await_registration_for,
          pip_requirements=pip_requirements,
          extra_pip_requirements=extra_pip_requirements,
          metadata=metadata,
          example_no_conversion=example_no_conversion,
          **kwargs,
      )
  
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 13 for calling a global function with example usage: log_model(model, task, artifact_path, conda_env, code_paths, registered_model_name, signature, input_example, await_registration_for, pip_requirements, extra_pip_requirements, metadata, example_no_conversion) and returns: Model