code: def load(cls: tp.Type[X], filepath: tp.PathLike) -> X:
      """Loads a pickle file and checks that it contains an optimizer.
      The optimizer class is not always fully reliable though (e.g.: optimizer families) so the user is responsible for it.
      """
      filepath = Path(filepath)
      with filepath.open("rb") as f:
          opt = pickle.load(f)
      assert isinstance(
          opt, cls
      ), f"You should only load {cls} with this method (found {type(opt)})"
      return opt
  
imports: import pickle
  import warnings
  from pathlib import Path
  from numbers import Real
  from collections import deque
  import numpy
  import nevergrad.common.typing
  from nevergrad.parametrization import parameter
  from nevergrad.common import tools
  from nevergrad.common import errors
  from nevergrad.common.decorators import Registry
  from .None import utils
  from .None import multiobjective
label_desc: Use image node_id 2 for calling a global function with example usage: load(cls, filepath) and returns: opt