class_docstr: Detect strings with length that is much longer/shorter than the identified "normal" string lengths.
  
  Parameters
  ----------
  columns :Union[Hashable, List[Hashable]] , default: None
      Columns to check, if none are given checks all columns except ignored ones.
  ignore_columns : Union[Hashable, List[Hashable]] , default: None
      Columns to ignore, if none given checks based on columns variable
  num_percentiles : int , default: 1000
      Number of percentiles values to retrieve for the length of the samples in the string
      column. Affects the resolution of string lengths that is used to detect outliers.
  inner_quantile_range : int , default: 94
      The int upper percentile [0-100] defining the inner percentile range.
      E.g. for 98 the range would be 2%-98%.
  outlier_factor : int , default: 4
      Strings would be defined as outliers if their length is outlier_factor times more/less
      than the values inside the inner quantile range.
  min_length_difference : int , default: 5
      The minimum length difference to be considered as outlier.
  min_length_ratio_difference : int , default: 0.5
      Used to calculate the minimum length difference to be considered as outlier. (calculated form this times the
      average of the normal lengths.)
  min_unique_value_ratio : float , default: 0.01
      Min
  min_unique_values : int , default: 100
      Minimum unique values in column to calculate string length outlier
  n_top_columns : int , optional
      amount of columns to show ordered by feature importance (date, index, label are first)
  outlier_length_to_show :int , default: 50
      Maximum length of outlier to show in results. If an outlier is longer it is trimmed and added '...'
  samples_per_range_to_show : int , default: 3
      Number of outlier samples to show in results per outlier range found.
  n_samples : int , default: 10_000_000
      number of samples to use for this check.
  random_state : int, default: 42
      random seed for all check internals.
class_docstr_tok: ["Detect","strings","with","length","that","is","much","longer\/shorter","than","the","identified","``","normal","''","string","lengths",".","Parameters","--","--","--","--","--","columns",":","Union","[","Hashable",",","List","[","Hashable","]","]",",","default",":","None","Columns","to","check",",","if","none","are","given","checks","all","columns","except","ignored","ones",".","ignore_columns",":","Union","[","Hashable",",","List","[","Hashable","]","]",",","default",":","None","Columns","to","ignore",",","if","none","given","checks","based","on","columns","variable","num_percentiles",":","int",",","default",":","1000","Number","of","percentiles","values","to","retrieve","for","the","length","of","the","samples","in","the","string","column",".","Affects","the","resolution","of","string","lengths","that","is","used","to","detect","outliers",".","inner_quantile_range",":","int",",","default",":","94","The","int","upper","percentile","[","0-100","]","defining","the","inner","percentile","range",".","E.g",".","for","98","the","range","would","be","2","%","-98","%",".","outlier_factor",":","int",",","default",":","4","Strings","would","be","defined","as","outliers","if","their","length","is","outlier_factor","times","more\/less","than","the","values","inside","the","inner","quantile","range",".","min_length_difference",":","int",",","default",":","5","The","minimum","length","difference","to","be","considered","as","outlier",".","min_length_ratio_difference",":","int",",","default",":","0.5","Used","to","calculate","the","minimum","length","difference","to","be","considered","as","outlier",".","(","calculated","form","this","times","the","average","of","the","normal","lengths",".",")","min_unique_value_ratio",":","float",",","default",":","0.01","Min","min_unique_values",":","int",",","default",":","100","Minimum","unique","values","in","column","to","calculate","string","length","outlier","n_top_columns",":","int",",","optional","amount","of","columns","to","show","ordered","by","feature","importance","(","date",",","index",",","label","are","first",")","outlier_length_to_show",":","int",",","default",":","50","Maximum","length","of","outlier","to","show","in","results",".","If","an","outlier","is","longer","it","is","trimmed","and","added","'","...","'","samples_per_range_to_show",":","int",",","default",":","3","Number","of","outlier","samples","to","show","in","results","per","outlier","range","found",".","n_samples",":","int",",","default",":","10_000_000","number","of","samples","to","use","for","this","check",".","random_state",":","int",",","default",":","42","random","seed","for","all","check","internals","."]
docstr: Add condition - require column's ratio of string length outliers to be less or equal to threshold.
  
  Parameters
  ----------
  max_ratio : float , default: 0
      Maximum allowed string length outliers ratio.
docstr_tok: ["Add","condition","-","require","column","'s","ratio","of","string","length","outliers","to","be","less","or","equal","to","threshold",".","Parameters","--","--","--","--","--","max_ratio",":","float",",","default",":","0","Maximum","allowed","string","length","outliers","ratio","."]
code: def add_condition_ratio_of_outliers_less_or_equal(
      self, max_ratio: float = 0
  ):
      """Add condition - require column's ratio of string length outliers to be less or equal to threshold.
  
      Parameters
      ----------
      max_ratio : float , default: 0
          Maximum allowed string length outliers ratio.
      """
  
      def compare_outlier_ratio(result: Dict):
          not_passing_columns = {}
          for column_name in result.keys():
              column = result[column_name]
              total_outliers = sum(
                  (
                      outlier["n_samples"]
                      for outlier in column["outliers"]
                  )
              )
              ratio = (
                  total_outliers / column["n_samples"]
                  if total_outliers > 0
                  else 0
              )
              if ratio > max_ratio:
                  not_passing_columns[column_name] = format_percent(
                      ratio
                  )
          if not_passing_columns:
              details = (
                  f"Found {len(not_passing_columns)} out of {len(result)} relevant columns with outliers "
                  f"ratio above threshold: {not_passing_columns}"
              )
              return ConditionResult(ConditionCategory.WARN, details)
          else:
              return ConditionResult(
                  ConditionCategory.PASS,
                  get_condition_passed_message(result),
              )
  
      return self.add_condition(
          f"Ratio of string length outliers is less or equal to {format_percent(max_ratio)}",
          compare_outlier_ratio,
      )
  
imports: from typing import Dict, List, Tuple, Union
  import numpy
  import pandas
  from pandas import DataFrame, Series
  from scipy import stats
  from deepchecks.core import CheckResult, ConditionCategory, ConditionResult
  from deepchecks.tabular import Context, SingleDatasetCheck
  from deepchecks.tabular.utils.feature_importance import N_TOP_MESSAGE, column_importance_sorter_df
  from deepchecks.tabular.utils.messages import get_condition_passed_message
  from deepchecks.utils.dataframes import select_from_dataframe
  from deepchecks.utils.strings import format_number, format_percent, is_string_column
  from deepchecks.utils.typing import Hashable
label_desc: Use image node_id 5 for calling the StringLengthOutOfBounds obj's underlying member method code with example usage: obj.add_condition_ratio_of_outliers_less_or_equal(max_ratio) and returns: self, ConditionResult, ConditionResult