class_docstr: Clearing house for multiple dispatch functionality. This class extends
  `<multipledispatch.Dispatcher>` by: (i) generalizing the argument encoding
  convention during method lookup, (ii) implementing `__getitem__` as a dedicated
  method lookup function.
class_docstr_tok: ["Clearing","house","for","multiple","dispatch","functionality",".","This","class","extends","`","<","multipledispatch.Dispatcher",">","`","by",":","(","i",")","generalizing","the","argument","encoding","convention","during","method","lookup",",","(","ii",")","implementing","`","__getitem__","`","as","a","dedicated","method","lookup","function","."]
docstr: Method lookup.
  
  Args:
      args: A set of arguments that act as identifiers for a stored method.
      types: A tuple of types that encodes `args`.
  
  Returns:
      A callable corresponding to the given `args` or `types`.
docstr_tok: ["Method","lookup",".","Args",":","args",":","A","set","of","arguments","that","act","as","identifiers","for","a","stored","method",".","types",":","A","tuple","of","types","that","encodes","`","args","`",".","Returns",":","A","callable","corresponding","to","the","given","`","args","`","or","`","types","`","."]
code: def __getitem__(
      self,
      args: Optional[Any] = None,
      types: Optional[Tuple[Type]] = None,
  ) -> Callable:
      r"""Method lookup.
  
      Args:
          args: A set of arguments that act as identifiers for a stored method.
          types: A tuple of types that encodes `args`.
  
      Returns:
          A callable corresponding to the given `args` or `types`.
      """
      if types is None:
          if args is None:
              raise RuntimeError(
                  "One of `args` or `types` must be provided."
              )
          types = self.encode_args(args)
      elif args is not None:
          raise RuntimeError(
              "Only one of `args` or `types` may be provided."
          )
  
      try:
          func = self._cache[types]
      except KeyError:
          func = self.dispatch(*types)
          if not func:
              msg = f"{self.name}: <{', '.join(cls.__name__ for cls in types)}"
              raise NotImplementedError(
                  f"Could not find signature for {msg}"
              )
          self._cache[types] = func
      return func
  
file_path: botorch/botorch/utils/dispatcher.py
imports: from __future__ import annotations
  from inspect import getsource, getsourcefile
  from typing import Any, Callable, Optional, Tuple, Type
  from multipledispatch.dispatcher import Dispatcher, MDNotImplementedError, str_signature
label_desc: Use image node_id 2 for calling the Dispatcher obj's underlying member method code with example usage: obj.__getitem__(args, types) and returns: func