def to_idx(item, mapper, unknown="@@@UNKNOWN@@@"):
  """
  :param item: Object
      Object to be encoded
  :param mapper: dict
      Dictionary from item to idx
  :param unknown: int
      Index of unknown item. If None, use len(mapper)
  It returns
  ----------
  idx : int
      Index of item
  """

  if item in mapper.keys():
    return mapper[item]
  return mapper["@@@UNKNOWN@@@"]

  if unknown is None:
    unknown = len(mapper)
  return mapper.get(item, unknown)