code: def _enforce_object(data: Dict[str, Any], obj: Object, required=True):
      if not required and data is None:
          return None
      if not isinstance(data, dict):
          raise MlflowException(
              f"Failed to enforce schema of '{data}' with type '{obj}'. "
              f"Expected data to be dictionary, got {type(data).__name__}"
          )
      if not isinstance(obj, Object):
          raise MlflowException(
              f"Failed to enforce schema of '{data}' with type '{obj}'. "
              f"Expected obj to be Object, got {type(obj).__name__}"
          )
      properties = {prop.name: prop for prop in obj.properties}
      required_props = {
          k for k, prop in properties.items() if prop.required
      }
      missing_props = required_props - set(data.keys())
      if missing_props:
          raise MlflowException(
              f"Missing required properties: {missing_props}"
          )
      if invalid_props := data.keys() - properties.keys():
          raise MlflowException(
              "Invalid properties not defined in the schema found: "
              f"{invalid_props}"
          )
      for k, v in data.items():
          try:
              data[k] = _enforce_property(v, properties[k])
          except MlflowException as e:
              raise MlflowException(
                  f"Failed to enforce schema for key `{k}`. "
                  f"Expected type {properties[k].to_dict()[k]['type']}, "
                  f"received type {type(v).__name__}"
              ) from e
      return data
  
imports: import datetime
  import decimal
  import json
  import logging
  import os
  from copy import deepcopy
  from typing import Any, Dict, List, Optional, Union
  import numpy
  import pandas
  from mlflow.exceptions import INVALID_PARAMETER_VALUE, MlflowException
  from mlflow.models import Model
  from mlflow.store.artifact.utils.models import get_model_name_and_version
  from mlflow.types import DataType, ParamSchema, ParamSpec, Schema, TensorSpec
  from mlflow.types.schema import Array, Object, Property
  from mlflow.types.utils import TensorsNotSupportedException, _infer_param_schema, clean_tensor_type
  from mlflow.utils.annotations import experimental
  from mlflow.utils.proto_json_utils import NumpyEncoder, dataframe_from_parsed_json, parse_tf_serving_input
  from mlflow.utils.uri import get_databricks_profile_uri_from_artifact_uri
label_desc: Use image node_id 19 for calling a global function with example usage: _enforce_object(data, obj, required) and returns: data, None