code: def bezier_unit_tangent(seg, t):
      
      assert 0 <= t <= 1
      dseg = seg.derivative(t)
  
      # Note: dseg might be numpy value, use np.seterr(invalid='raise')
      try:
          unit_tangent = dseg/abs(dseg)
      except (ZeroDivisionError, FloatingPointError):
          # This may be a removable singularity, if so we just need to compute
          # the limit.
          # Note: limit{{dseg / abs(dseg)} = sqrt(limit{dseg**2 / abs(dseg)**2})
          dseg_poly = seg.poly().deriv()
          dseg_abs_squared_poly = (real(dseg_poly) ** 2 +
                                   imag(dseg_poly) ** 2)
          try:
              unit_tangent = csqrt(rational_limit(dseg_poly**2,
                                              dseg_abs_squared_poly, t))
          except ValueError:
              bef = seg.poly().deriv()(t - 1e-4)
              aft = seg.poly().deriv()(t + 1e-4)
              mes = ("Unit tangent appears to not be well-defined at "
                     "t = {}, \n".format(t) +
                     "seg.poly().deriv()(t - 1e-4) = {}\n".format(bef) +
                     "seg.poly().deriv()(t + 1e-4) = {}".format(aft))
              raise ValueError(mes)
      return unit_tangent
docs: Returns the unit tangent of the segment at t.
  
      Notes
      -----
      If you receive a RuntimeWarning, try the following:
      >>> import numpy
      >>> old_numpy_error_settings = numpy.seterr(invalid='raise')
      This can be undone with:
      >>> numpy.seterr(**old_numpy_error_settings)