class_docstr: A piece of text with associated style. Segments are produced by the Console render process and
  are ultimately converted in to strings to be written to the terminal.
  
  Args:
      text (str): A piece of text.
      style (:class:`~rich.style.Style`, optional): An optional style to apply to the text.
      control (Tuple[ControlCode], optional): Optional sequence of control codes.
  
  Attributes:
      cell_length (int): The cell length of this Segment.
docstr: Aligns lines to middle (adds extra lines to above and below as required).
  
          Args:
              lines (List[List[Segment]]): A list of lines.
              width (int): Desired width.
              height (int, optional): Desired height or None for no change.
              style (Style): Style of any padding added.
              new_lines (bool, optional): Padded lines should include "
  ". Defaults to False.
  
          Returns:
              List[List[Segment]]: New list of lines.
          
docstr_tok: ["Aligns","lines","to","middle","(","adds","extra","lines","to","above","and","below","as","required",")",".","Args",":","lines","(","List","[","List","[","Segment","]","]",")",":","A","list","of","lines",".","width","(","int",")",":","Desired","width",".","height","(","int",",","optional",")",":","Desired","height","or","None","for","no","change",".","style","(","Style",")",":","Style","of","any","padding","added",".","new_lines","(","bool",",","optional",")",":","Padded","lines","should","include","``","''",".","Defaults","to","False",".","Returns",":","List","[","List","[","Segment","]","]",":","New","list","of","lines","."]
code: def align_middle(
      cls: Type["Segment"],
      lines: List[List["Segment"]],
      width: int,
      height: int,
      style: Style,
      new_lines: bool = False,
  ) -> List[List["Segment"]]:
      """Aligns lines to middle (adds extra lines to above and below as required).
  
      Args:
          lines (List[List[Segment]]): A list of lines.
          width (int): Desired width.
          height (int, optional): Desired height or None for no change.
          style (Style): Style of any padding added.
          new_lines (bool, optional): Padded lines should include "\n". Defaults to False.
  
      Returns:
          List[List[Segment]]: New list of lines.
      """
      extra_lines = height - len(lines)
      if not extra_lines:
          return lines[:]
      lines = lines[:height]
      blank = (
          cls(" " * width + "\n", style)
          if new_lines
          else cls(" " * width, style)
      )
      top_lines = extra_lines // 2
      bottom_lines = extra_lines - top_lines
      lines = [[blank]] * top_lines + lines + [[blank]] * bottom_lines
      return lines
  
imports: from enum import IntEnum
  from functools import lru_cache
  from itertools import filterfalse
  from logging import getLogger
  from operator import attrgetter
  from typing import TYPE_CHECKING, Dict, Iterable, List, NamedTuple, Optional, Sequence, Tuple, Type, Union
  from .cells import _is_single_cell_widths, cached_cell_len, cell_len, get_character_cell_size, set_cell_size
  from .repr import Result, rich_repr
  from .style import Style
label_desc: Use image node_id 18 for calling the Segment obj's underlying member method code with example usage: obj.align_middle(cls, lines, width, height, style, new_lines) and returns: lines, lines