docstr: Checks if the given text fits within the context window given by `max_request_length`.
  Since the encoder-decoder models have separate maximum context lengths for the input prompts
  vs. the completions, we check the two values separately.
docstr_tok: ["Checks","if","the","given","text","fits","within","the","context","window","given","by","`","max_request_length","`",".","Since","the","encoder-decoder","models","have","separate","maximum","context","lengths","for","the","input","prompts","vs.","the","completions",",","we","check","the","two","values","separately","."]
code: def fits_within_context_window(
      self, text: str, expected_completion_token_length: int = 0
  ) -> bool:
      """
      Checks if the given text fits within the context window given by `max_request_length`.
      Since the encoder-decoder models have separate maximum context lengths for the input prompts
      vs. the completions, we check the two values separately.
      """
      if expected_completion_token_length > self.max_output_length:
          hlog(
              f"WARNING: The expected completion token length ({expected_completion_token_length}) "
              f"exceeds the max output length ({self.max_output_length})."
          )
      return self.get_num_tokens(text) <= self.max_request_length
  
file_path: H2O/h2o_hf/helm/src/helm/benchmark/window_services/encoder_decoder_window_service.py
imports: from abc import ABC
  from helm.common.hierarchical_logger import hlog
  from .local_window_service import LocalWindowService
  from .tokenizer_service import TokenizerService
label_desc: Use image node_id 4 for calling the EncoderDecoderWindowService obj's underlying member method code with example usage: obj.fits_within_context_window(text, expected_completion_token_length) and returns: unknown