def METHOD_NAME(self, x: Union[torch.LongTensor, List[str]]) -> Optional[torch.Tensor]:
    """
    Args:
        x: A batch of `N` identifiers. Either a long tensor of size
        `(N,)` keys in [0, n_instances), or a list of `N` string keys that
        are hashed to codes (without collisions).
    Returns:
        codes: A tensor of shape `(N, self.encoding_dim)` containing the
            key-specific autodecoder codes.
    """
    if self.ignore_input:
        x = ["singleton"]
    if isinstance(x[0], str):
        try:
            # pyre-fixme[9]: x has type `Union[List[str], LongTensor]`; used as
            #  `Tensor`.
            x = torch.tensor(
                [self._key_map[elem] for elem in x],
                dtype=torch.long,
                device=next(self.parameters()).device,
            )
        except StopIteration:
            raise ValueError("Not enough n_instances in the autodecoder") from None
    return self._autodecoder_codes(x)