code: def _validate_fields(
      sample_collection,
      field_names,
      allowed_label_types,
      same_type,
      frames=False,
  ):
      if frames:
          schema = sample_collection.get_frame_field_schema()
      else:
          schema = sample_collection.get_field_schema()
  
      label_types = {}
      for field_name in field_names:
          if field_name not in schema:
              ftype = "frame field" if frames else "sample field"
              raise ValueError(
                  "%s has no %s '%s'"
                  % (
                      sample_collection.__class__.__name__,
                      ftype,
                      field_name,
                  )
              )
  
          field = schema[field_name]
  
          try:
              label_type = field.document_type
          except:
              label_type = field
  
          if label_type not in allowed_label_types:
              ftype = "Frame field" if frames else "Sample field"
              raise ValueError(
                  "%s '%s' is not a %s instance; found %s"
                  % (ftype, field_name, allowed_label_types, label_type)
              )
  
          label_types[field_name] = label_type
  
      if same_type and len(set(label_types.values())) > 1:
          ftype = "Frame fields" if frames else "Sample fields"
          raise ValueError(
              "%s %s must have the same type; found %s"
              % (ftype, field_names, label_types)
          )
  
file_path: fiftyone/fiftyone/core/validation.py
imports: import eta.core.utils
  import fiftyone.core.media
  import fiftyone.core.utils
label_desc: Use image node_id 8 for calling a global function with example usage: _validate_fields(sample_collection, field_names, allowed_label_types, same_type, frames) without return types