code: def _dihedral_affine(k:partial(uniform_int,0,7)):
      "Randomly flip `x` image based on `k`."
      x = -1 if k&1 else 1
      y = -1 if k&2 else 1
      if k&4: return [[0, x, 0.],
                      [y, 0, 0],
                      [0, 0, 1.]]
      return [[x, 0, 0.],
              [0, y, 0],
              [0, 0, 1.]f _dihedral_affine(k:partial(uniform_int,0,7)):
      "Randomly flip `x` image based on `k`."
      x = -1 if k&1 else 1
      y = -1 if k&2 else 1
      if k&4: return [[0, x, 0.],
                      [y, 0, 0],
                      [0, 0, 1.]]
      return [[x, 0, 0.],
              [0, y, 0],
              [0, 0, 1.]]
docs: Randomly flip `x` image based on `k`.