class_docstr: Class representing a rectangle.
class_docstr_tok: ["Class","representing","a","rectangle","."]
docstr: Contracts the rectangle by the given margins.
  
  @return: a new L{Rectangle} object.
docstr_tok: ["Contracts","the","rectangle","by","the","given","margins",".","@","return",":","a","new","L","{","Rectangle","}","object","."]
code: def contract(self, margins):
      """Contracts the rectangle by the given margins.
  
      @return: a new L{Rectangle} object.
      """
      if isinstance(margins, int) or isinstance(margins, float):
          margins = [float(margins)] * 4
      if len(margins) != 4:
          raise ValueError(
              "margins must be a 4-tuple or a single number"
          )
      nx1, ny1 = self._left + margins[0], self._top + margins[1]
      nx2, ny2 = self._right - margins[2], self._bottom - margins[3]
      if nx1 > nx2:
          nx1 = (nx1 + nx2) / 2.0
          nx2 = nx1
      if ny1 > ny2:
          ny1 = (ny1 + ny2) / 2.0
          ny2 = ny1
      return self.__class__(nx1, ny1, nx2, ny2)
  
imports: from collections import defaultdict
  from math import atan2, cos, hypot, sin
  from typing import NamedTuple
  from igraph.utils import consecutive_pairs
label_desc: Use image node_id 22 for calling the Rectangle obj's underlying member method code with example usage: obj.contract(margins) and returns: self