(decode_fn, features)
return "".join([
      "%d: %s\n" % (i, decode_fn(inputs[i]))
      for i in selected_ids
      if i >= 0 and i < num_inputs
  ])
Decode selected indices from features dict.
Decode selected indices from features dict.
Decode selected indices from features dict .
def decode_selected_indices(decode_fn, features):
  """Decode selected indices from features dict."""
  inputs = features.get("inputs", None)
  selected_ids = features.get("selected_ids", None)
  num_inputs = features.get("num_inputs", None)
  if inputs is None or selected_ids is None or num_inputs is None:
    raise ValueError("Insufficient input fields.")
  if len(inputs.shape) != 2:
    raise ValueError("Expected prediction['inputs'] to have two dimensions.")
  return "".join([
      "%d: %s\n" % (i, decode_fn(inputs[i]))
      for i in selected_ids
      if i >= 0 and i < num_inputs
  ])
def decode_selected_indices ( decode_fn , features ) : inputs = features . get ( "inputs" , None ) selected_ids = features . get ( "selected_ids" , None ) num_inputs = features . get ( "num_inputs" , None ) if inputs is None or selected_ids is None or num_inputs is None : raise ValueError ( "Insufficient input fields." ) if len ( inputs . shape ) != 2 : raise ValueError ( "Expected prediction['inputs'] to have two dimensions." ) return "" . join ( [ "%d: %s\n" % ( i , decode_fn ( inputs [ i ] ) ) for i in selected_ids if i >= 0 and i < num_inputs ] )