code: def validate(data, schema=None):
      
      schema = _load_schema_for_record(data, schema)
  
      return jsonschema_validate(
          instance=data,
          schema=schema,
          resolver=LocalRefResolver.from_schema(schema),
          format_checker=inspire_format_checker,
      )
docs: Validate the given dictionary against the given schema.
  
      Args:
          data (dict): record to validate.
          schema (Union[dict, str]): schema to validate against. If it is a
              string, it is intepreted as the name of the schema to load (e.g.
              ``authors`` or ``jobs``). If it is ``None``, the schema is taken
              from ``data['$schema']``. If it is a dictionary, it is used
              directly.
  
      Raises:
          SchemaNotFound: if the given schema was not found.
          SchemaKeyNotFound: if ``schema`` is ``None`` and no ``$schema`` key was
              found in ``data``.
          jsonschema.SchemaError: if the schema is invalid.
          jsonschema.ValidationError: if the data is invalid.