class_docstr: The loss function maker.
docstr: Initializes a loss function maker.
  
  Args:
    loss_keys: A string or list of strings representing loss keys defined in
      `RankingLossKey`. Listed loss functions will be combined in a weighted
      manner, with weights specified by `loss_weights`. If `loss_weights` is
      None, default weight of 1 will be used. The loss_keys could also be of
      form 'mean_squared_loss:0.1,softmax_loss:0.9' in which case it will be
      parsed as a list of loss keys `['mean_squared_loss', 'softmax_loss']`
      and corresponding loss weights `[0.1, 0.9]`.
    loss_weights: List of weights, same length as `loss_keys`. Used when
      merging losses to calculate the weighted sum of losses. If `None`, all
      losses are weighted equally with weight being 1.
    weights_feature_name: A string specifying the name of the weights feature
      in `features` dict.
    lambda_weight: A `_LambdaWeight` object created by factory methods like
      `create_ndcg_lambda_weight()`.
    reduction: One of `tf.losses.Reduction` except `NONE`. Describes how to
      reduce training loss over batch.
    name: A string used as the name for this loss.
    params: A string-keyed dictionary that contains any other loss-specific
      arguments.
    gumbel_params: A string-keyed dictionary that contains other
      `gumbel_softmax_sample` arguments.
docstr_tok: ["Initializes","a","loss","function","maker",".","Args",":","loss_keys",":","A","string","or","list","of","strings","representing","loss","keys","defined","in","`","RankingLossKey","`",".","Listed","loss","functions","will","be","combined","in","a","weighted","manner",",","with","weights","specified","by","`","loss_weights","`",".","If","`","loss_weights","`","is","None",",","default","weight","of","1","will","be","used",".","The","loss_keys","could","also","be","of","form","'mean_squared_loss:0.1",",","softmax_loss:0.9","'","in","which","case","it","will","be","parsed","as","a","list","of","loss","keys","`","[","'mean_squared_loss","'",",","'softmax_loss","'","]","`","and","corresponding","loss","weights","`","[","0.1",",","0.9","]","`",".","loss_weights",":","List","of","weights",",","same","length","as","`","loss_keys","`",".","Used","when","merging","losses","to","calculate","the","weighted","sum","of","losses",".","If","`","None","`",",","all","losses","are","weighted","equally","with","weight","being","1.","weights_feature_name",":","A","string","specifying","the","name","of","the","weights","feature","in","`","features","`","dict",".","lambda_weight",":","A","`","_LambdaWeight","`","object","created","by","factory","methods","like","`","create_ndcg_lambda_weight","(",")","`",".","reduction",":","One","of","`","tf.losses.Reduction","`","except","`","NONE","`",".","Describes","how","to","reduce","training","loss","over","batch",".","name",":","A","string","used","as","the","name","for","this","loss",".","params",":","A","string-keyed","dictionary","that","contains","any","other","loss-specific","arguments",".","gumbel_params",":","A","string-keyed","dictionary","that","contains","other","`","gumbel_softmax_sample","`","arguments","."]
code: def __init__(
      self,
      loss_keys: Union[str, Sequence[str]],
      loss_weights: Optional[Sequence[Union[float, int]]] = None,
      weights_feature_name: Optional[str] = None,
      lambda_weight: Optional[losses_impl._LambdaWeight] = None,
      reduction: tf.compat.v1.losses.Reduction = tf.compat.v1.losses.Reduction.SUM_BY_NONZERO_WEIGHTS,
      name: Optional[str] = None,
      params: Optional[Mapping[str, Any]] = None,
      gumbel_params: Optional[Mapping[str, Any]] = None,
  ):
      """Initializes a loss function maker.
  
      Args:
        loss_keys: A string or list of strings representing loss keys defined in
          `RankingLossKey`. Listed loss functions will be combined in a weighted
          manner, with weights specified by `loss_weights`. If `loss_weights` is
          None, default weight of 1 will be used. The loss_keys could also be of
          form 'mean_squared_loss:0.1,softmax_loss:0.9' in which case it will be
          parsed as a list of loss keys `['mean_squared_loss', 'softmax_loss']`
          and corresponding loss weights `[0.1, 0.9]`.
        loss_weights: List of weights, same length as `loss_keys`. Used when
          merging losses to calculate the weighted sum of losses. If `None`, all
          losses are weighted equally with weight being 1.
        weights_feature_name: A string specifying the name of the weights feature
          in `features` dict.
        lambda_weight: A `_LambdaWeight` object created by factory methods like
          `create_ndcg_lambda_weight()`.
        reduction: One of `tf.losses.Reduction` except `NONE`. Describes how to
          reduce training loss over batch.
        name: A string used as the name for this loss.
        params: A string-keyed dictionary that contains any other loss-specific
          arguments.
        gumbel_params: A string-keyed dictionary that contains other
          `gumbel_softmax_sample` arguments.
      """
  
      if isinstance(loss_keys, str) and (
          ":" in loss_keys or "," in loss_keys
      ):
          if loss_weights is not None:
              raise ValueError(
                  "`loss_weights` has to be None when weights are encoded in `loss_keys`."
              )
          keys_to_weights = utils.parse_keys_and_weights(loss_keys)
          loss_keys = list(keys_to_weights.keys())
          loss_weights = list(keys_to_weights.values())
  
      self.loss_keys = loss_keys
      self.loss_weights = loss_weights
      self.weights_feature_name = weights_feature_name
      self.lambda_weight = lambda_weight
      self.reduction = reduction
      self.name = name
      self.params = params or {}
      self.gumbel_params = gumbel_params or {}
  
imports: from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Tuple, Union
  import tensorflow
  from tensorflow_ranking.python import losses_impl
  from tensorflow_ranking.python import utils
label_desc: Use image node_id 1 to create a new _LossFunctionMaker object from inherited base classes: object with example: obj = _LossFunctionMaker(loss_keys, loss_weights, weights_feature_name, lambda_weight, reduction, name, params, gumbel_params)