code: def _is_inventory_group(key, value):
      '''
      Verify that a module-level variable (key = value) is a valid inventory group.
      '''
  
      if (
          key.startswith('_')
          or not isinstance(value, (list, tuple, GeneratorType))
      ):
          return False
  
      # If the group is a tuple of (hosts, data), check the hosts
      if isinstance(value, tuple):
          value = value[0]
  
      # Expand any generators of hosts
      if isinstance(value, GeneratorType):
          value = list(value)
  
      return all(
          isinstance(item, ALLOWED_HOST_TYPES)
          for item in value
      f _is_inventory_group(key, value):
      '''
      Verify that a module-level variable (key = value) is a valid inventory group.
      '''
  
      if (
          key.startswith('_')
          or not isinstance(value, (list, tuple, GeneratorType))
      ):
          return False
  
      # If the group is a tuple of (hosts, data), check the hosts
      if isinstance(value, tuple):
          value = value[0]
  
      # Expand any generators of hosts
      if isinstance(value, GeneratorType):
          value = list(value)
  
      return all(
          isinstance(item, ALLOWED_HOST_TYPES)
          for item in value
      )
docs: Verify that a module-level variable (key = value) is a valid inventory group.