code: def try_import_msgpack(error: bool = False):
      """Tries importing msgpack and msgpack_numpy and returns the patched msgpack module.
  
      Returns None if error is False and msgpack or msgpack_numpy is not installed.
      Raises an error, if error is True and the modules could not be imported.
  
      Args:
          error: Whether to raise an error if msgpack/msgpack_numpy cannot be imported.
  
      Returns:
          The `msgpack` module.
  
      Raises:
          ImportError: If error=True and msgpack/msgpack_numpy is not installed.
      """
      try:
          import msgpack
          import msgpack_numpy
  
          # Make msgpack_numpy look like msgpack.
          msgpack_numpy.patch()
  
          return msgpack
  
      except Exception:
          if error:
              raise ImportError(
                  "Could not import or setup msgpack and msgpack_numpy! "
                  "Try running `pip install msgpack msgpack_numpy` first."
              )
  
file_path: ray/python/ray/rllib/utils/checkpoints.py
imports: import logging
  import json
  import os
  from packaging import version
  import re
  from typing import Any, Dict, Union
  import ray
  from ray.rllib.utils.serialization import NOT_SERIALIZABLE, serialize_type
  from ray.train import Checkpoint
  from ray.util import log_once
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 4 for calling a global function with example usage: try_import_msgpack(error) and returns: msgpack