code: def replace_anc(dataset, parent_dataset):
      
      if parent_dataset is None:
          return
      current_dsid = DatasetID.from_dict(dataset.attrs)
      for idx, ds in enumerate(parent_dataset.attrs['ancillary_variables']):
          if current_dsid == DatasetID.from_dict(ds.attrs):
              parent_dataset.attrs['ancillary_variables'][idx] = dataset
              return
docs: Replace *dataset* the *parent_dataset*'s `ancillary_variables` field.