code: def validate(self, data):
          
          if data is not None and not isinstance(data, dict):
              raise serializers.ValidationError("Invalid data")
  
          try:
              profiles = [ev["profile"] for ev in data.get("encoded_videos", [])]
              if len(profiles) != len(set(profiles)):
                  raise serializers.ValidationError("Invalid data: duplicate profiles")
          except KeyError:
              raise serializers.ValidationError("profile required for deserializing")
          except TypeError:
              raise serializers.ValidationError("profile field needs to be a profile_name (str)")
  
          # Clean course_video list from any invalid data.
          course_videos = [(course_video, image) for course_video, image in data.get('courses', []) if course_video]
          data['courses'] = course_videos
  
          return data
docs: Check that the video data is valid.