class_docstr: Private class for the n-dimensional hypersphere.
  
  Class for the n-dimensional hypersphere embedded in the
  (n+1)-dimensional Euclidean space.
  
  By default, points are parameterized by their extrinsic
  (n+1)-coordinates. For dimensions 1 and 2, this can be changed with the
  `default_coords_type` parameter. For dimensions 1 (the circle),
  the intrinsic coordinates correspond angles in radians, with 0. mapping
  to point [1., 0.]. For dimension 2, the intrinsic coordinates are the
  spherical coordinates from the north pole, i.e. where angles [0., 0.]
  correspond to point [0., 0., 1.].
  
  Parameters
  ----------
  dim : int
      Dimension of the hypersphere.
  
  default_coords_type : str, {'extrinsic', 'intrinsic'}
      Type of representation for dimensions 1 and 2.
docstr: Convert tangent vector from extrinsic to spherical coordinates.
  
  Convert a tangent vector from the extrinsic coordinates in Euclidean
  space to the spherical coordinates in the hypersphere for.
  Spherical coordinates are considered from the north pole [0., 0.,
  1.]. This method is only implemented in dimension 2.
  
  Parameters
  ----------
  tangent_vec : array-like, shape=[..., 3]
      Tangent vector to the sphere, in spherical coordinates.
  base_point : array-like, shape=[..., 3]
      Point on the sphere. Unused if `base_point_spherical` is given.
      Optional, default : None.
  base_point_spherical : array-like, shape=[..., 2]
      Point on the sphere, in spherical coordinates. Either
      `base_point` or `base_point_spherical` must be given.
      Optional, default : None.
  
  Returns
  -------
  tangent_vec_spherical : array-like, shape=[..., 2]
      Tangent vector to the sphere, at base point,
      in spherical coordinates relative to the north pole [0., 0., 1.].
docstr_tok: ["Convert","tangent","vector","from","extrinsic","to","spherical","coordinates",".","Convert","a","tangent","vector","from","the","extrinsic","coordinates","in","Euclidean","space","to","the","spherical","coordinates","in","the","hypersphere","for",".","Spherical","coordinates","are","considered","from","the","north","pole","[","0.",",","0.",",","1.","]",".","This","method","is","only","implemented","in","dimension","2",".","Parameters","--","--","--","--","--","tangent_vec",":","array-like",",","shape=","[","...",",","3","]","Tangent","vector","to","the","sphere",",","in","spherical","coordinates",".","base_point",":","array-like",",","shape=","[","...",",","3","]","Point","on","the","sphere",".","Unused","if","`","base_point_spherical","`","is","given",".","Optional",",","default",":","None",".","base_point_spherical",":","array-like",",","shape=","[","...",",","2","]","Point","on","the","sphere",",","in","spherical","coordinates",".","Either","`","base_point","`","or","`","base_point_spherical","`","must","be","given",".","Optional",",","default",":","None",".","Returns","--","--","--","-","tangent_vec_spherical",":","array-like",",","shape=","[","...",",","2","]","Tangent","vector","to","the","sphere",",","at","base","point",",","in","spherical","coordinates","relative","to","the","north","pole","[","0.",",","0.",",","1",".","]","."]
code: def tangent_extrinsic_to_spherical(
      self, tangent_vec, base_point=None, base_point_spherical=None
  ):
      """Convert tangent vector from extrinsic to spherical coordinates.
  
      Convert a tangent vector from the extrinsic coordinates in Euclidean
      space to the spherical coordinates in the hypersphere for.
      Spherical coordinates are considered from the north pole [0., 0.,
      1.]. This method is only implemented in dimension 2.
  
      Parameters
      ----------
      tangent_vec : array-like, shape=[..., 3]
          Tangent vector to the sphere, in spherical coordinates.
      base_point : array-like, shape=[..., 3]
          Point on the sphere. Unused if `base_point_spherical` is given.
          Optional, default : None.
      base_point_spherical : array-like, shape=[..., 2]
          Point on the sphere, in spherical coordinates. Either
          `base_point` or `base_point_spherical` must be given.
          Optional, default : None.
  
      Returns
      -------
      tangent_vec_spherical : array-like, shape=[..., 2]
          Tangent vector to the sphere, at base point,
          in spherical coordinates relative to the north pole [0., 0., 1.].
      """
      if self.dim != 2:
          raise NotImplementedError(
              "The conversion from to extrinsic coordinates "
              "spherical coordinates is implemented"
              " only in dimension 2."
          )
      if base_point is None and base_point_spherical is None:
          raise ValueError(
              "A base point must be given, either in "
              "extrinsic or in spherical coordinates."
          )
      if base_point_spherical is None and base_point is not None:
          base_point_spherical = self.extrinsic_to_spherical(base_point)
  
      axes = (2, 0, 1) if base_point_spherical.ndim == 2 else (0, 1)
      theta = base_point_spherical[..., 0]
      phi = base_point_spherical[..., 1]
  
      theta_safe = gs.where(gs.abs(theta) < gs.atol, gs.atol, theta)
      zeros = gs.zeros_like(theta)
      jac_close_0 = gs.array(
          [
              [gs.ones_like(theta), zeros, zeros],
              [zeros, gs.ones_like(theta), zeros],
          ]
      )
  
      jac = gs.array(
          [
              [
                  gs.cos(theta) * gs.cos(phi),
                  gs.cos(theta) * gs.sin(phi),
                  -gs.sin(theta),
              ],
              [
                  -gs.sin(phi) / gs.sin(theta_safe),
                  gs.cos(phi) / gs.sin(theta_safe),
                  zeros,
              ],
          ]
      )
  
      jac = gs.transpose(jac, axes)
      jac_close_0 = gs.transpose(jac_close_0, axes)
      theta_criterion = gs.einsum(
          "...,...ij->...ij", theta, gs.ones_like(jac)
      )
      jac = gs.where(
          gs.abs(theta_criterion) < gs.atol, jac_close_0, jac
      )
  
      return gs.einsum("...ij,...j->...i", jac, tangent_vec)
  
imports: import logging
  import math
  from itertools import product
  from scipy.stats import beta
  import geomstats.algebra_utils
  import geomstats.backend
  from geomstats.geometry.base import LevelSet
  from geomstats.geometry.euclidean import Euclidean
  from geomstats.geometry.riemannian_metric import RiemannianMetric
  from geomstats.vectorization import get_batch_shape, repeat_out
label_desc: Use image node_id 13 for calling the _Hypersphere obj's underlying member method code with example usage: obj.tangent_extrinsic_to_spherical(tangent_vec, base_point, base_point_spherical) and returns: gs