class_docstr: Stores the mapping between callee and caller methods for a router.
  
  This class is primarily used in a ``get_metadata_routing()`` of a router
  object when defining the mapping between a sub-object (a sub-estimator or a
  scorer) to the router's methods. It stores a collection of ``Route``
  namedtuples.
  
  Iterating through an instance of this class will yield named
  ``MethodPair(callee, caller)`` tuples.
  
  .. versionadded:: 1.3
class_docstr_tok: ["Stores","the","mapping","between","callee","and","caller","methods","for","a","router",".","This","class","is","primarily","used","in","a","``","get_metadata_routing","(",")","``","of","a","router","object","when","defining","the","mapping","between","a","sub-object","(","a","sub-estimator","or","a","scorer",")","to","the","router","'s","methods",".","It","stores","a","collection","of","``","Route","``","namedtuples",".","Iterating","through","an","instance","of","this","class","will","yield","named","``","MethodPair","(","callee",",","caller",")","``","tuples",".","..","versionadded",":",":","1.3"]
docstr: Construct an instance from a string.
  
  Parameters
  ----------
  route : str
      A string representing the mapping, it can be:
  
        - `"one-to-one"`: a one to one mapping for all methods.
        - `"method"`: the name of a single method, such as ``fit``,
          ``transform``, ``score``, etc.
  
  Returns
  -------
  obj : MethodMapping
      A :class:`~sklearn.utils.metadata_routing.MethodMapping` instance
      constructed from the given string.
docstr_tok: ["Construct","an","instance","from","a","string",".","Parameters","--","--","--","--","--","route",":","str","A","string","representing","the","mapping",",","it","can","be",":","-","`","``","one-to-one","''","`",":","a","one","to","one","mapping","for","all","methods",".","-","`","``","method","''","`",":","the","name","of","a","single","method",",","such","as","``","fit","``",",","``","transform","``",",","``","score","``",",","etc",".","Returns","--","--","--","-","obj",":","MethodMapping","A",":","class",":","`","~sklearn.utils.metadata_routing.MethodMapping","`","instance","constructed","from","the","given","string","."]
code: def from_str(cls, route):
      """Construct an instance from a string.
  
      Parameters
      ----------
      route : str
          A string representing the mapping, it can be:
  
            - `"one-to-one"`: a one to one mapping for all methods.
            - `"method"`: the name of a single method, such as ``fit``,
              ``transform``, ``score``, etc.
  
      Returns
      -------
      obj : MethodMapping
          A :class:`~sklearn.utils.metadata_routing.MethodMapping` instance
          constructed from the given string.
      """
      routing = cls()
      if route == "one-to-one":
          for method in METHODS:
              routing.add(callee=method, caller=method)
      elif route in METHODS:
          routing.add(callee=route, caller=route)
      else:
          raise ValueError(
              "route should be 'one-to-one' or a single method!"
          )
      return routing
  
imports: import inspect
  from collections import namedtuple
  from copy import deepcopy
  from typing import TYPE_CHECKING, Optional, Union
  from warnings import warn
  from ..None import get_config
  from ..exceptions import UnsetMetadataPassedError
  from ._bunch import Bunch
label_desc: Use image node_id 5 for calling the MethodMapping obj's underlying member method code with example usage: obj.from_str(cls, route) and returns: routing