code: def get_method(
      algname: str,
      methods: Mapping[str, Callable],
      method: Union[str, Callable],
  ) -> Callable:
      """Get a method from a dictionary of methods
  
      Examples
      --------
      >>> get_method('foo', {'bar': lambda: 1}, 'bar')()
      1
  
      Parameters
      ----------
      algname: str
          Name of the algorithm
      methods: dict
          Dictionary of methods
      method: str or callable
          Method to get
  
      Returns
      -------
      callable
          The method
  
      """
  
      if isinstance(method, str):
          methodname = method.lower()
          if methodname in methods:
              return methods[methodname]
          else:
              raise RuntimeError(
                  "Unknown %s method: %s" % (algname, method)
              )
      elif hasattr(method, "__call__"):
          return method
      elif method is None:
          assert False, (
              "Internal assert failed, method in get_method is not supposed"
              "to be None. If this shows, then the corresponding function fails to "
              "set the default method"
          )
      else:
          raise TypeError(
              "Invalid method type: %s. Only str and callable are accepted."
              % type(method)
          )
  
file_path: deepchem/deepchem/utils/differentiation_utils/misc.py
imports: import contextlib
  import copy
  from typing import Mapping, Callable, Union, Dict, List
label_desc: Use image node_id 3 for calling a global function with example usage: get_method(algname, methods, method) and returns: methods, method