code: def models_max_input_output_length(
      models: List[SockeyeModel],
      num_stds: int,
      forced_max_input_length: Optional[int] = None,
      forced_max_output_length: 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.
      Mean and std are taken from the model with the largest values to allow proper ensembling of models
      trained on different data sets.
  
      :param models: List of models.
      :param num_stds: Number of standard deviations to add as a safety margin. If -1, returned maximum output lengths
                       will always be 2 * input_length.
      :param forced_max_input_length: An optional overwrite of the maximum input length. Does not include eos.
      :param forced_max_output_length: 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.
      """
      max_mean = max(model.length_ratio_mean for model in models)
      max_std = max(model.length_ratio_std for model in models)
      supported_max_seq_len_source = min(
          (model.max_supported_len_source for model in models)
      )
      supported_max_seq_len_target = min(
          (model.max_supported_len_target for model in models)
      )
      return get_max_input_output_length(
          supported_max_seq_len_source,
          supported_max_seq_len_target,
          length_ratio_mean=max_mean,
          length_ratio_std=max_std,
          num_stds=num_stds,
          forced_max_input_len=forced_max_input_length,
          forced_max_output_len=forced_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 1 for calling a global function with example usage: models_max_input_output_length(models, num_stds, forced_max_input_length, forced_max_output_length) and returns: get_max_input_output_length