code: def _sanitize_params(params: Dict[str, Any]) -> Dict[str, Any]:
      """Returns params with non-primitvies converted to strings for logging.
  
      >>> import torch
      >>> params = {"float": 0.3,
      ...           "int": 1,
      ...           "string": "abc",
      ...           "bool": True,
      ...           "list": [1, 2, 3],
      ...           "namespace": Namespace(foo=3),
      ...           "layer": torch.nn.BatchNorm1d}
      >>> import pprint
      >>> pprint.pprint(_sanitize_params(params))  # doctest: +NORMALIZE_WHITESPACE
      {'bool': True,
          'float': 0.3,
          'int': 1,
          'layer': "<class 'torch.nn.modules.batchnorm.BatchNorm1d'>",
          'list': '[1, 2, 3]',
          'namespace': 'Namespace(foo=3)',
          'string': 'abc'}
  
      """
      for k in params:
          # convert relevant np scalars to python types first (instead of str)
          if isinstance(params[k], (np.bool_, np.integer, np.floating)):
              params[k] = params[k].item()
          elif type(params[k]) not in [bool, int, float, str, Tensor]:
              params[k] = str(params[k])
      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 4 for calling a global function with example usage: _sanitize_params(params) and returns: params