code: def is_field_boolean(source: DataSource, field: str) -> bool:
      """Returns a boolean indicating whether the object field should have a bool dtype.
  
      Columns with object dtype that have 3 distinct values of which one is Nan/None is a bool type column.
      """
      unique_values = source.df[field].unique()
      if len(unique_values) <= 3:
          for entry in unique_values:
              try:
                  if np.isnan(entry):
                      continue
              except TypeError:
                  # For some field types such as object arrays, np.isnan throws a TypeError
                  # In this case, do nothing and proceed to checking if the entry is a bool object
                  pass
              if isinstance(entry, bool):
                  continue
              return False
          return True
      return False
  
imports: import logging
  import os
  from dataclasses import dataclass
  from typing import Any, Dict, List, Set, Union
  import dask.dataframe
  import numpy
  import pandas
  import yaml
  from dataclasses_json import dataclass_json, LetterCase
  from tqdm import tqdm
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.backend import Backend
  from ludwig.constants import COLUMN, COMBINER, ENCODER, EXECUTOR, HYPEROPT, INPUT_FEATURES, PREPROCESSING, SCHEDULER, SEARCH_ALG, SPLIT, TEXT, TYPE
  from ludwig.types import ModelConfigDict
  from ludwig.utils.automl.data_source import DataSource, wrap_data_source
  from ludwig.utils.automl.field_info import FieldConfig, FieldInfo, FieldMetadata
  from ludwig.utils.automl.type_inference import infer_type, should_exclude
  from ludwig.utils.data_utils import load_yaml
  from ludwig.utils.misc_utils import merge_dict
  from ludwig.utils.system_utils import Resources
label_desc: Use image node_id 8 for calling a global function with example usage: is_field_boolean(source, field) and returns: False, True, False