code: def _validate_attrs(dataset):
      
      def check_attr(name, value):
          if isinstance(name, str):
              if not name:
                  raise ValueError('Invalid name for attr: string must be '
                                   'length 1 or greater for serialization to '
                                   'netCDF files')
          else:
              raise TypeError("Invalid name for attr: {} must be a string for "
                              "serialization to netCDF files".format(name))
  
          if not isinstance(value, (str, Number, np.ndarray, np.number,
                                    list, tuple)):
              raise TypeError('Invalid value for attr: {} must be a number, '
                              'a string, an ndarray or a list/tuple of '
                              'numbers/strings for serialization to netCDF '
                              'files'.format(value))
  
      # Check attrs on the dataset itself
      for k, v in dataset.attrs.items():
          check_attr(k, v)
  
      # Check attrs on each variable within the dataset
      for variable in dataset.variables.values():
          for k, v in variable.attrs.items():
              check_attr(k, v)
docs: `attrs` must have a string key and a value which is either: a number,
      a string, an ndarray or a list/tuple of numbers/strings.