def get_token_offsets_from_text_field_inputs(
    text_field_inputs: List[Any],
) -> Optional[torch.Tensor]:
    """
    Given a list of inputs to a TextFieldEmbedder, tries to find token offsets from those inputs, if
    there are any.  You will have token offsets if you are using a mismatched token embedder; if
    you're not, the return value from this function should be None.  This function is intended to be
    called from a `forward_hook` attached to a `TextFieldEmbedder`, so the inputs are formatted just
    as a list.

    It's possible in theory that you could have multiple offsets as inputs to a single call to a
    `TextFieldEmbedder`, but that's an extremely rare use case (I can't really imagine anyone
    wanting to do that).  In that case, we'll only return the first one.  If you need different
    behavior for your model, open an issue on github describing what you're doing.
    """
    for input_index, text_field_input in enumerate(text_field_inputs):
        if not isinstance(text_field_input, dict):
            continue
        for input_value in text_field_input.values():
            if not isinstance(input_value, dict):
                continue
            for embedder_arg_name, embedder_arg_value in input_value.items():
                if embedder_arg_name == "offsets":
                    return embedder_arg_value
    return None
Given a list of inputs to a TextFieldEmbedder, tries to find token offsets from those inputs, if
there are any.  You will have token offsets if you are using a mismatched token embedder; if
you're not, the return value from this function should be None.  This function is intended to be
called from a `forward_hook` attached to a `TextFieldEmbedder`, so the inputs are formatted just
as a list.

It's possible in theory that you could have multiple offsets as inputs to a single call to a
`TextFieldEmbedder`, but that's an extremely rare use case (I can't really imagine anyone
wanting to do that).  In that case, we'll only return the first one.  If you need different
behavior for your model, open an issue on github describing what you're doing.
allennlp/nn/util.py