code: def concatenate(samplesets, defaults=None):
      
  
      itertup = iter(samplesets)
  
      try:
          first = next(itertup)
      except StopIteration:
          raise ValueError("samplesets must contain at least one SampleSet")
  
      vartype = first.vartype
      variables = first.variables
  
      records = [first.record]
      records.extend(_iter_records(itertup, vartype, variables))
  
      # dev note: I was able to get ~2x performance boost when trying to
      # implement the same functionality here by hand (I didn't know that
      # this function existed then). However I think it is better to use
      # numpy's function and rely on their testing etc. If however this becomes
      # a performance bottleneck in the future, it might be worth changing.
      record = recfunctions.stack_arrays(records, defaults=defaults,
                                         asrecarray=True, usemask=False)
  
      return SampleSet(record, variables, {}, vartype)
docs: Combine SampleSets.
  
      Args:
          samplesets (iterable[:obj:`.SampleSet`):
              An iterable of sample sets.
  
          defaults (dict, optional):
              Dictionary mapping data vector names to the corresponding default values.
  
      Returns:
          :obj:`.SampleSet`: A sample set with the same vartype and variable order as the first
          given in `samplesets`.
  
      Examples:
          >>> a = dimod.SampleSet.from_samples(([-1, +1], 'ab'), dimod.SPIN, energy=-1)
          >>> b = dimod.SampleSet.from_samples(([-1, +1], 'ba'), dimod.SPIN, energy=-1)
          >>> ab = dimod.concatenate((a, b))
          >>> ab.record.sample
          array([[-1,  1],
                 [ 1, -1]], dtype=int8)