code: def _validate_dataset_names(dataset):
      
      def check_name(name):
          if isinstance(name, str):
              if not name:
                  raise ValueError('Invalid name for DataArray or Dataset key: '
                                   'string must be length 1 or greater for '
                                   'serialization to netCDF files')
          elif name is not None:
              raise TypeError('DataArray.name or Dataset key must be either a '
                              'string or None for serialization to netCDF files')
  
      for k in dataset.variables:
          check_name(k)
docs: DataArray.name and Dataset keys must be a string or None