<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def genhash(frame,**kw):
    '''
    Generate the hashes for the given frame for a specification
    given in the dictionary d returned from firsthash.

    Parameters:
    -----------
      frame :  frame to hash.

    Keywords:
    ---------
      d         : hash specification generated from firsthash.
      new       : use new hashing, which isn't really hashing.
      removedups: put -1 in duplicates,
      dims      : specify dims. Supercedes the setting in `d'.
      dupes     : array of hashes known to be dupes.
      ftype     : type of floats. defaults to 'f'.

    -- old keywords from old hashing --
      mins      : minima of each axis
      avgdifs   : average differences
      pw        : powers of each axis

    Returns an array of the shape of the frames with hashes.
    '''
    getkw = mk_getkw(kw,genhash_defaults,prefer_passed=True);
    dims = getkw('dims');
    dupes= getkw('dupes');
    if not getkw('new'):
        ip = np.array([frame['data'][l] for l in dims]).T;
        scaled = ((ip - getkw('mins'))/getkw('avgdiffs')).round().astype('int64');
        hashes = (scaled*getkw('pw')).sum(axis=1).astype('int64');
    else:
        hashes = np.array([
            struct.pack('{}{}'.format(len(dims),getkw('ftype')), *[p[l] for l in dims])
            for p in frame['data']]);
    if getkw('removedupes'):
        #marking duplicated particles
        if not getkw('dupes'):
            hashes =  np.unique(hashes);
        else:
            dupei = np.in1d(hashes, getkw('dupes'));
            hashes[dupei] = -1
    return hashes;