code: def contains_rigid(self):
          
          if self._check_if_contains_rigid_bodies:
              self._check_if_contains_rigid_bodies = False
              if any(particle.rigid_id is not None for particle in self._particles()):
                  self._contains_rigid = True
              else:
                  self._contains_rigid = False
          return self._contains_rigid
docs: Returns True if the Compound contains rigid bodies
  
          If the Compound contains any particle with a rigid_id != None
          then contains_rigid will return True. If the Compound has no
          children (i.e. the Compound resides at the bottom of the containment
          hierarchy) then contains_rigid will return False.
  
          Returns
          -------
          bool
              True if the Compound contains any particle with a rigid_id != None
  
          Notes
          -----
          The private variable '_check_if_contains_rigid_bodies' is used to help
          cache the status of 'contains_rigid'. If '_check_if_contains_rigid_bodies'
          is False, then the rigid body containment of the Compound has not changed,
          and the particle tree is not traversed, boosting performance.