<s>[INST] In a school district, students of different grade levels take part in the annual talent show. You have been tasked to calculate the total number of students who participate in the show. The district consists of multiple schools. You can count the students for each grade level in each school separately. 

### Assumptions

- Students of grade levels K to 12 participate in the talent show
- Each school can only have students from one grade level to ten participating in the talent show, with a maximum of 3 students per grade level.
- The number of students in each grade level can be scrapped separately from the school website.

### Tasks

1. Create a class called `Student` that has a `name` and a `grade_level`.
2. Create a class called `School` with the following methods.
   - `__init__` method that initializes a school and sets it name and a rating (1-5).
   - An `add_student` method that can add a student to the school.
   - A `get_total_students` method that returns the total number of students in the school.
   - A `get_students_by_grade` method that returns a dictionary where keys are grade levels and values are a list of students.
3. Create a `SchoolDistrict` class that can keep track of all schools and their corresponding data.
   - `__init__` method that initializes the school district.
   - An `add_school` method that can add a school to the district.
   - A `get_total_students_district` method that returns the total number of students in the district.
   - A `get_total_students_by_grade_district` method that returns the total number of students for each grade level across all schools in the district.

### Implementation

In terms of implementation, you need to consider the following:
- Not all schools have students in all grade levels. 
- A school may have multiple students in one grade level.
- You will need to validate the grade levels (K-12) when adding a student to a school. 

Here's some example use cases to get you started.

```python
# create a school
school1 = School("School 1", 5)

# add students to the school
school1.add_student(Student("John Doe", 9))
school1.add_student(Student("Jane Doe", 9))
school1.add_student(Student("Mike Williams", 10))

# display total students in the school
print(school1.get_total_students())

# display students by grade in the school
print(school1.get_students_by_grade())

# create a school district
district = SchoolDistrict()

# add school to the district
district.add_school(school1)

# add another school to the district
school2 = School("School 2", 4)
district.add_school(school2)
school2.add_student(Student("Michael Davis", 8))

# display total students in the district
print(district.get_total_students_district())

# display students by grade in the district
print(district.get_total_students_by_grade_district())
```

### Requirements

- Test all the functionality with Pytest.
- Implement a way to handle an edge case where the same student is added twice to the same school, or to different schools.

This problem is designed to assess your ability to write a Python program using object-oriented programming (OOP) concepts. The program should be able to model a school district, schools in the district, students in a school, and count the total number of students in the district or by grade level. The program should handle edge cases such as adding the same student to the same or different schools.

Would you like me to help you with this?[/INST]