code: def dict_like(value, name, optional=False, strict=True):
      """
      Check if dict_like (dict, Mapping) or raise if not
  
      Parameters
      ----------
      value : object
          Value to verify
      name : str
          Variable name for exceptions
      optional : bool
          Flag indicating whether None is allowed
      strict : bool
          If True, then only allow dict. If False, allow any Mapping-like object.
  
      Returns
      -------
      converted : dict_like
          value
      """
      if optional and value is None:
          return None
      if not isinstance(value, Mapping) or (
          strict and not (isinstance(value, dict))
      ):
          extra_text = "If not None, " if optional else ""
          strict_text = (
              " or dict_like (i.e., a Mapping)" if strict else ""
          )
          msg = f"{extra_text}{name} must be a dict{strict_text}"
          raise TypeError(msg)
      return value
  
file_path: statsmodels/statsmodels/tools/validation/validation.py
imports: from typing import Any, Optional
  from collections.abc import Mapping
  import numpy
  import pandas
label_desc: Use image node_id 8 for calling a global function with example usage: dict_like(value, name, optional, strict) and returns: value, None