docstr: Validate if the given line is valid.
  
  This function should only be used for training.
docstr_tok: ["Validate","if","the","given","line","is","valid",".","This","function","should","only","be","used","for","training","."]
code: def is_valid_line(
      self,
      text,
      downscaled_line_len,
      full_line_len,
      line_id: str,
      print_warnings=True,
  ):
      """Validate if the given line is valid.
  
      This function should only be used for training.
      """
  
      if self.mode in {PipelineMode.TRAINING, PipelineMode.EVALUATION}:
          # Check that the line is not too long (if activated)
          if self.params.max_line_width > 0:
              if full_line_len > self.params.max_line_width:
                  if print_warnings:
                      logger.warning(
                          f"Invalid line, line too long: {full_line_len} > {self.params.max_line_width} (id={line_id})"
                      )
                  return False
  
          # Check for empty lines
          if len(text) == 0:
              logger.warning(
                  f"Skipping empty line with empty GT (id={line_id})"
              )
              return False
  
          # Check if the line is long enough so that there is a possible CTC-path (after subsampling)
          last_char = -1
          required_blanks = 0
          for char in text:
              if last_char == char:
                  required_blanks += 1
              last_char = char
  
          required_len = len(text) + required_blanks
          if required_len > downscaled_line_len:
              if print_warnings:
                  logger.warning(
                      f"Invalid line (longer outputs than inputs) (id={line_id})"
                  )
              return False
  
      return True
  
file_path: calamari/calamari_ocr/ocr/dataset/imageprocessors/preparesample.py
imports: import logging
  from dataclasses import dataclass, field
  from typing import Type
  import numpy
  from paiargparse import pai_dataclass, pai_meta
  from tfaip.data.pipeline.definitions import PipelineMode, Sample
  from tfaip.data.pipeline.processor.dataprocessor import DataProcessorParams, MappingDataProcessor
label_desc: Use image node_id 2 for calling the PrepareSample obj's underlying member method code with example usage: obj.is_valid_line(text, downscaled_line_len, full_line_len, line_id, print_warnings) and returns: True, False, False, False