code: def infer_method_params(
      cls: Type[T], method: Callable
  ) -> Dict[str, inspect.Parameter]:
      signature = inspect.signature(method)
      parameters = dict(signature.parameters)
  
      has_kwargs = False
      var_positional_key = None
      for param in parameters.values():
          if param.kind == param.VAR_KEYWORD:
              has_kwargs = True
          elif param.kind == param.VAR_POSITIONAL:
              var_positional_key = param.name
  
      if var_positional_key:
          del parameters[var_positional_key]
  
      if not has_kwargs:
          return parameters
  
      # "mro" is "method resolution order". The first one is the current class, the next is the
      # first superclass, and so on. We take the first superclass we find that inherits from
      # FromParams.
      super_class = None
      for super_class_candidate in cls.mro()[1:]:
          if issubclass(super_class_candidate, FromParams):
              super_class = super_class_candidate
              break
      if super_class:
          super_parameters = infer_params(super_class)
      else:
          super_parameters = {}
  
      return {**super_parameters, **parameters}
  
imports: import collections.abc
  from copy import deepcopy
  from pathlib import Path
  from typing import Any, Callable, cast, Dict, Iterable, List, Mapping, Set, Tuple, Type, TypeVar, Union, Optional
  import inspect
  import logging
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.lazy import Lazy
  from allennlp.common.params import Params
label_desc: Use image node_id 7 for calling a global function with example usage: infer_method_params(cls, method) and returns: dict, parameters