code: def _convert_params(
      params: Optional[Union[Dict[str, Any], Namespace]]
  ) -> Dict[str, Any]:
      """Ensure parameters are a dict or convert to dict if necessary.
  
      Args:
          params: Target to be converted to a dictionary
  
      Returns:
          params as a dictionary
  
      """
      # in case converting from namespace
      if isinstance(params, Namespace):
          params = vars(params)
  
      if params is None:
          params = {}
  
      return params
  
file_path: pytorch-lightning/src/lightning/fabric/utilities/logger.py
imports: from argparse import Namespace
  from dataclasses import asdict, is_dataclass
  from typing import Any, Dict, Mapping, MutableMapping, Optional, Union
  import numpy
  from torch import Tensor
label_desc: Use image node_id 1 for calling a global function with example usage: _convert_params(params) and returns: params