code: def get_max_input_output_length(
      supported_max_seq_len_source: int,
      supported_max_seq_len_target: int,
      length_ratio_mean: float,
      length_ratio_std: float,
      num_stds: int,
      forced_max_input_len: Optional[int] = None,
      forced_max_output_len: Optional[int] = None,
  ) -> Tuple[int, Callable]:
      """
      Returns a function to compute maximum output length given a fixed number of standard deviations as a
      safety margin, and the current input length. It takes into account optional maximum source and target lengths.
  
      :param supported_max_seq_len_source: The maximum source length supported by the models (includes eos).
      :param supported_max_seq_len_target: The maximum target length supported by the models (includes bos).
      :param length_ratio_mean: Length ratio mean computed on the training data (including bos/eos).
      :param length_ratio_std: The standard deviation of the length ratio.
      :param num_stds: The number of standard deviations the target length may exceed the mean target length (as long as
             the supported maximum length allows for this).
      :param forced_max_input_len: An optional overwrite of the maximum input length. Does not include eos.
      :param forced_max_output_len: An optional overwrite of the maximum output length. Does not include bos.
      :return: The maximum input length and a function to get the output length given the input length.
      """
  
      if num_stds < 0:
          factor = C.TARGET_MAX_LENGTH_FACTOR  # type: float
      else:
          factor = length_ratio_mean + (length_ratio_std * num_stds)
  
      if forced_max_input_len is not None:
          max_input_len = min(
              supported_max_seq_len_source,
              forced_max_input_len + C.SPACE_FOR_XOS,
          )
      else:
          max_input_len = supported_max_seq_len_source
  
      def get_max_output_length(input_length: int):
          """
          Returns the maximum output length (including bos/eos) for inference given an input length that includes <eos>.
          """
          if forced_max_output_len is not None:
              return forced_max_output_len + C.SPACE_FOR_XOS
          return int(np.ceil(factor * input_length))
  
      return max_input_len, get_max_output_length
  
imports: import copy
  import itertools
  import json
  import logging
  from dataclasses import dataclass
  from functools import partial
  from typing import Any, Callable, Dict, Generator, List, Optional, Set, Tuple, Union
  import numpy
  import torch
  from .None import constants
  from .None import lexicon
  from .None import utils
  from .None import vocab
  from .beam_search import CandidateScorer, get_search_algorithm, GreedySearch, SearchResult
  from .data_io import tokens2ids, get_prepended_token_length
  from .model import SockeyeModel
label_desc: Use image node_id 2 for calling a global function with example usage: get_max_input_output_length(supported_max_seq_len_source, supported_max_seq_len_target, length_ratio_mean, length_ratio_std, num_stds, forced_max_input_len, forced_max_output_len) and returns: max_input_len,  get_max_output_length, int, unknown