class_docstr: Applies regularizers to the parameters of a Module based on regex matches.
docstr: Converts a List of pairs (regex, params) into an RegularizerApplicator.
  This list should look like
  
  [["regex1": {"type": "l2", "alpha": 0.01}], ["regex2": "l1"]]
  
  where each parameter receives the penalty corresponding to the first regex
  that matches its name (which may be no regex and hence no penalty).
  The values can either be strings, in which case they correspond to the names
  of regularizers, or dictionaries, in which case they must contain the "type"
  key, corresponding to the name of a regularizer. In addition, they may contain
  auxiliary named parameters which will be fed to the regularizer itself.
  To determine valid auxiliary parameters, please refer to the torch.nn.init documentation.
  
  Parameters
  ----------
  params : ``Params``, required.
      A Params object containing a "regularizers" key.
  
  Returns
  -------
  A RegularizerApplicator containing the specified Regularizers,
  or ``None`` if no Regularizers are specified.
docstr_tok: ["Converts","a","List","of","pairs","(","regex",",","params",")","into","an","RegularizerApplicator",".","This","list","should","look","like","[","[","``","regex1","''",":","{","``","type","''",":","``","l2","''",",","``","alpha","''",":","0.01","}","]",",","[","``","regex2","''",":","``","l1","''","]","]","where","each","parameter","receives","the","penalty","corresponding","to","the","first","regex","that","matches","its","name","(","which","may","be","no","regex","and","hence","no","penalty",")",".","The","values","can","either","be","strings",",","in","which","case","they","correspond","to","the","names","of","regularizers",",","or","dictionaries",",","in","which","case","they","must","contain","the","``","type","''","key",",","corresponding","to","the","name","of","a","regularizer",".","In","addition",",","they","may","contain","auxiliary","named","parameters","which","will","be","fed","to","the","regularizer","itself",".","To","determine","valid","auxiliary","parameters",",","please","refer","to","the","torch.nn.init","documentation",".","Parameters","--","--","--","--","--","params",":","``","Params","``",",","required",".","A","Params","object","containing","a","``","regularizers","''","key",".","Returns","--","--","--","-","A","RegularizerApplicator","containing","the","specified","Regularizers",",","or","``","None","``","if","no","Regularizers","are","specified","."]
code: def from_params(cls, params=()):
      """
      Converts a List of pairs (regex, params) into an RegularizerApplicator.
      This list should look like
  
      [["regex1": {"type": "l2", "alpha": 0.01}], ["regex2": "l1"]]
  
      where each parameter receives the penalty corresponding to the first regex
      that matches its name (which may be no regex and hence no penalty).
      The values can either be strings, in which case they correspond to the names
      of regularizers, or dictionaries, in which case they must contain the "type"
      key, corresponding to the name of a regularizer. In addition, they may contain
      auxiliary named parameters which will be fed to the regularizer itself.
      To determine valid auxiliary parameters, please refer to the torch.nn.init documentation.
  
      Parameters
      ----------
      params : ``Params``, required.
          A Params object containing a "regularizers" key.
  
      Returns
      -------
      A RegularizerApplicator containing the specified Regularizers,
      or ``None`` if no Regularizers are specified.
      """
      if not params:
          return None
  
      instantiated_regularizers = []
      for parameter_regex, regularizer_params in params:
          if isinstance(regularizer_params, unicode):
              regularizer = Regularizer.by_name(regularizer_params)()
          else:
              regularizer_type = Regularizer.by_name(
                  regularizer_params.pop("type")
              )
              regularizer = regularizer_type(**regularizer_params)  # type: ignore
          instantiated_regularizers.append(
              (parameter_regex, regularizer)
          )
      return RegularizerApplicator(instantiated_regularizers)
  
file_path: magnitude/pymagnitude/third_party/allennlp/nn/regularizers/regularizer_applicator.py
imports: from __future__ import absolute_import
  import re
  import torch
  from allennlp.common.params import Params
  from allennlp.nn.regularizers.regularizer import Regularizer
label_desc: Use image node_id 3 for calling the RegularizerApplicator obj's underlying member method code with example usage: obj.from_params(cls, params) and returns: RegularizerApplicator, None