






import unittest

from transformers import PegasusTokenizer, PegasusTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin


UpperCAmelCase     :     Dict							=	get_tests_dir("""fixtures/test_sentencepiece_no_bos.model""")







@require_sentencepiece
@require_tokenizers
class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : List[str]            =      PegasusTokenizer
      _lowercase    : Any            =      PegasusTokenizerFast
      _lowercase    : str            =      True
      _lowercase    : Any            =      True







      def        _lowercase  (   self							)       ->						Dict:



        '''simple docstring'''




        super().setUp()

        # We have a SentencePiece fixture for testing
        a__     : Optional[int]  =PegasusTokenizer(lowerCAmelCase__							)
        tokenizer.save_pretrained(self.tmpdirname							)







      @cached_property
      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        return PegasusTokenizer.from_pretrained("google/pegasus-large"							)







      def        _lowercase  (   self		,				**lowerCAmelCase__							)       ->						PegasusTokenizer:



        '''simple docstring'''




        return PegasusTokenizer.from_pretrained(self.tmpdirname		,				**lowerCAmelCase__							)







      def        _lowercase  (   self		,				lowerCAmelCase__							)       ->						List[Any]:



        '''simple docstring'''




        return ("This is a test", "This is a test")







      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        a__     : Optional[int]  ="</s>"
        a__     : List[str]  =1

        self.assertEqual(self.get_tokenizer()._convert_token_to_id(lowerCAmelCase__							)		,				lowerCAmelCase__							)
        self.assertEqual(self.get_tokenizer()._convert_id_to_token(lowerCAmelCase__							)		,				lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						Optional[Any]:



        '''simple docstring'''




        a__     : Tuple  =list(self.get_tokenizer().get_vocab().keys()							)

        self.assertEqual(vocab_keys[0]		,				"<pad>"							)
        self.assertEqual(vocab_keys[1]		,				"</s>"							)
        self.assertEqual(vocab_keys[-1]		,				"v"							)
        self.assertEqual(len(lowerCAmelCase__							)		,				1_1_0_3							)







      def        _lowercase  (   self							)       ->						List[str]:



        '''simple docstring'''




        self.assertEqual(self.get_tokenizer().vocab_size		,				1_1_0_3							)







      def        _lowercase  (   self							)       ->						Optional[Any]:



        '''simple docstring'''




        a__     : Optional[int]  =self.rust_tokenizer_class.from_pretrained(self.tmpdirname							)
        a__     : Dict  =self.tokenizer_class.from_pretrained(self.tmpdirname							)
        a__     : Dict  =(
            "Let's see which <unk> is the better <unk_token_11> one <mask_1> It seems like this <mask_2> was important"
            " </s> <pad> <pad> <pad>"
        )
        a__     : List[str]  =rust_tokenizer([raw_input_str]		,				return_tensors=lowerCAmelCase__		,				add_special_tokens=lowerCAmelCase__							).input_ids[0]
        a__     : Tuple  =py_tokenizer([raw_input_str]		,				return_tensors=lowerCAmelCase__		,				add_special_tokens=lowerCAmelCase__							).input_ids[0]
        self.assertListEqual(lowerCAmelCase__		,				lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						Any:



        '''simple docstring'''




        a__     : Tuple  =self._large_tokenizer
        # <mask_1> masks whole sentence while <mask_2> masks single word
        a__     : Dict  ="<mask_1> To ensure a <mask_2> flow of bank resolutions."
        a__     : str  =[2, 4_1_3, 6_1_5, 1_1_4, 3, 1_9_7_1, 1_1_3, 1_6_7_9, 1_0_7_1_0, 1_0_7, 1]
        a__     : Dict  =tokenizer([raw_input_str]		,				return_tensors=lowerCAmelCase__							).input_ids[0]
        self.assertListEqual(lowerCAmelCase__		,				lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						Optional[Any]:



        '''simple docstring'''




        a__     : Any  =self._large_tokenizer
        # The tracebacks for the following asserts are **better** without messages or self.assertEqual
        assert tokenizer.vocab_size == 9_6_1_0_3
        assert tokenizer.pad_token_id == 0
        assert tokenizer.eos_token_id == 1
        assert tokenizer.offset == 1_0_3
        assert tokenizer.unk_token_id == tokenizer.offset + 2 == 1_0_5
        assert tokenizer.unk_token == "<unk>"
        assert tokenizer.model_max_length == 1_0_2_4
        a__     : Dict  ="To ensure a smooth flow of bank resolutions."
        a__     : Union[str, Any]  =[4_1_3, 6_1_5, 1_1_4, 2_2_9_1, 1_9_7_1, 1_1_3, 1_6_7_9, 1_0_7_1_0, 1_0_7, 1]
        a__     : List[Any]  =tokenizer([raw_input_str]		,				return_tensors=lowerCAmelCase__							).input_ids[0]
        self.assertListEqual(lowerCAmelCase__		,				lowerCAmelCase__							)
        assert tokenizer.convert_ids_to_tokens([0, 1, 2, 3]							) == ["<pad>", "</s>", "<mask_1>", "<mask_2>"]







      @require_torch
      def        _lowercase  (   self							)       ->						Dict:



        '''simple docstring'''




        a__     : str  =["This is going to be way too long." * 1_5_0, "short example"]
        a__     : Any  =["not super long but more than 5 tokens", "tiny"]
        a__     : Union[str, Any]  =self._large_tokenizer(lowerCAmelCase__		,				padding=lowerCAmelCase__		,				truncation=lowerCAmelCase__		,				return_tensors="pt"							)
        a__     : Any  =self._large_tokenizer(
            text_target=lowerCAmelCase__		,				max_length=5		,				padding=lowerCAmelCase__		,				truncation=lowerCAmelCase__		,				return_tensors="pt"							)

        assert batch.input_ids.shape == (2, 1_0_2_4)
        assert batch.attention_mask.shape == (2, 1_0_2_4)
        assert targets["input_ids"].shape == (2, 5)
        assert len(lowerCAmelCase__							) == 2  # input_ids, attention_mask.







      @slow
      def        _lowercase  (   self							)       ->						int:



        '''simple docstring'''




        a__     : Any  ={"input_ids": [[3_8_9_7_9, 1_4_3, 1_8_4_8_5, 6_0_6, 1_3_0, 2_6_6_6_9, 8_7_6_8_6, 1_2_1, 5_4_1_8_9, 1_1_2_9, 1_1_1, 2_6_6_6_9, 8_7_6_8_6, 1_2_1, 9_1_1_4, 1_4_7_8_7, 1_2_1, 1_3_2_4_9, 1_5_8, 5_9_2, 9_5_6, 1_2_1, 1_4_6_2_1, 3_1_5_7_6, 1_4_3, 6_2_6_1_3, 1_0_8, 9_6_8_8, 9_3_0, 4_3_4_3_0, 1_1_5_6_2, 6_2_6_1_3, 3_0_4, 1_0_8, 1_1_4_4_3, 8_9_7, 1_0_8, 9_3_1_4, 1_7_4_1_5, 6_3_3_9_9, 1_0_8, 1_1_4_4_3, 7_6_1_4, 1_8_3_1_6, 1_1_8, 4_2_8_4, 7_1_4_8, 1_2_4_3_0, 1_4_3, 1_4_0_0, 2_5_7_0_3, 1_5_8, 1_1_1, 4_2_8_4, 7_1_4_8, 1_1_7_7_2, 1_4_3, 2_1_2_9_7, 1_0_6_4, 1_5_8, 1_2_2, 2_0_4, 3_5_0_6, 1_7_5_4, 1_1_3_3, 1_4_7_8_7, 1_5_8_1, 1_1_5, 3_3_2_2_4, 4_4_8_2, 1_1_1, 1_3_5_5, 1_1_0, 2_9_1_7_3, 3_1_7, 5_0_8_3_3, 1_0_8, 2_0_1_4_7, 9_4_6_6_5, 1_1_1, 7_7_1_9_8, 1_0_7, 1], [1_1_0, 6_2_6_1_3, 1_1_7, 6_3_8, 1_1_2, 1_1_3_3, 1_2_1, 2_0_0_9_8, 1_3_5_5, 7_9_0_5_0, 1_3_8_7_2, 1_3_5, 1_5_9_6, 5_3_5_4_1, 1_3_5_2, 1_4_1, 1_3_0_3_9, 5_5_4_2, 1_2_4, 3_0_2, 5_1_8, 1_1_1, 2_6_8, 2_9_5_6, 1_1_5, 1_4_9, 4_4_2_7, 1_0_7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1_3_9, 1_2_3_5, 2_7_9_9, 1_8_2_8_9, 1_7_7_8_0, 2_0_4, 1_0_9, 9_4_7_4, 1_2_9_6, 1_0_7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "attention_mask": [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
        # fmt: on

        self.tokenizer_integration_test_util(
            expected_encoding=lowerCAmelCase__		,				model_name="google/bigbird-pegasus-large-arxiv"		,				revision="ba85d0851d708441f91440d509690f1ab6353415"		,				)







@require_sentencepiece
@require_tokenizers
class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Dict            =      PegasusTokenizer
      _lowercase    : Optional[int]            =      PegasusTokenizerFast
      _lowercase    : List[str]            =      True
      _lowercase    : int            =      True







      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        super().setUp()

        # We have a SentencePiece fixture for testing
        a__     : str  =PegasusTokenizer(lowerCAmelCase__		,				offset=0		,				mask_token_sent=lowerCAmelCase__		,				mask_token="[MASK]"							)
        tokenizer.save_pretrained(self.tmpdirname							)







      @cached_property
      def        _lowercase  (   self							)       ->						List[str]:



        '''simple docstring'''




        return PegasusTokenizer.from_pretrained("google/bigbird-pegasus-large-arxiv"							)







      def        _lowercase  (   self		,				**lowerCAmelCase__							)       ->						PegasusTokenizer:



        '''simple docstring'''




        return PegasusTokenizer.from_pretrained(self.tmpdirname		,				**lowerCAmelCase__							)







      def        _lowercase  (   self		,				lowerCAmelCase__							)       ->						Any:



        '''simple docstring'''




        return ("This is a test", "This is a test")







      def        _lowercase  (   self							)       ->						Any:



        '''simple docstring'''




        a__     : int  =self.rust_tokenizer_class.from_pretrained(self.tmpdirname							)
        a__     : int  =self.tokenizer_class.from_pretrained(self.tmpdirname							)
        a__     : Any  =(
            "Let's see which <unk> is the better <unk_token> one [MASK] It seems like this [MASK] was important </s>"
            " <pad> <pad> <pad>"
        )
        a__     : List[Any]  =rust_tokenizer([raw_input_str]		,				return_tensors=lowerCAmelCase__		,				add_special_tokens=lowerCAmelCase__							).input_ids[0]
        a__     : str  =py_tokenizer([raw_input_str]		,				return_tensors=lowerCAmelCase__		,				add_special_tokens=lowerCAmelCase__							).input_ids[0]
        self.assertListEqual(lowerCAmelCase__		,				lowerCAmelCase__							)







      @require_torch
      def        _lowercase  (   self							)       ->						List[Any]:



        '''simple docstring'''




        a__     : List[Any]  =["This is going to be way too long." * 1_0_0_0, "short example"]
        a__     : int  =["not super long but more than 5 tokens", "tiny"]
        a__     : Any  =self._large_tokenizer(lowerCAmelCase__		,				padding=lowerCAmelCase__		,				truncation=lowerCAmelCase__		,				return_tensors="pt"							)
        a__     : List[str]  =self._large_tokenizer(
            text_target=lowerCAmelCase__		,				max_length=5		,				padding=lowerCAmelCase__		,				truncation=lowerCAmelCase__		,				return_tensors="pt"							)

        assert batch.input_ids.shape == (2, 4_0_9_6)
        assert batch.attention_mask.shape == (2, 4_0_9_6)
        assert targets["input_ids"].shape == (2, 5)
        assert len(lowerCAmelCase__							) == 2  # input_ids, attention_mask.







      def        _lowercase  (   self							)       ->						Union[str, Any]:



        '''simple docstring'''




        a__     : List[Any]  =(
            "This is an example string that is used to test the original TF implementation against the HF"
            " implementation"
        )

        a__     : Tuple  =self._large_tokenizer(lowerCAmelCase__							).input_ids

        self.assertListEqual(
            lowerCAmelCase__		,				[1_8_2, 1_1_7, 1_4_2, 5_8_7, 4_2_1_1, 1_2_0, 1_1_7, 2_6_3, 1_1_2, 8_0_4, 1_0_9, 8_5_6, 2_5_0_1_6, 3_1_3_7, 4_6_4, 1_0_9, 2_6_9_5_5, 3_1_3_7, 1]		,				)













from math import acos, sin
from typing import List, Tuple, Union

import numpy as np
import torch
from PIL import Image

from ...models import AutoencoderKL, UNetaDConditionModel
from ...schedulers import DDIMScheduler, DDPMScheduler
from ...utils import randn_tensor
from ..pipeline_utils import AudioPipelineOutput, BaseOutput, DiffusionPipeline, ImagePipelineOutput
from .mel import Mel







class     __lowerCAmelCase	(   UpperCamelCase__):
      _lowercase    : str            =      ["""vqvae"""]







      def __init__(   self		,				lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__		,				)       ->						Union[str, Any]:



        '''simple docstring'''




        super().__init__()
        self.register_modules(unet=lowerCAmelCase__		,				scheduler=lowerCAmelCase__		,				mel=lowerCAmelCase__		,				vqvae=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						int:



        '''simple docstring'''




        return 5_0 if isinstance(self.scheduler		,				lowerCAmelCase__							) else 1_0_0_0







      @torch.no_grad()
      def __call__(   self		,				lowerCAmelCase__ = 1		,				lowerCAmelCase__ = None		,				lowerCAmelCase__ = None		,				lowerCAmelCase__ = 0		,				lowerCAmelCase__ = 0		,				lowerCAmelCase__ = None		,				lowerCAmelCase__ = None		,				lowerCAmelCase__ = 0		,				lowerCAmelCase__ = 0		,				lowerCAmelCase__ = None		,				lowerCAmelCase__ = 0		,				lowerCAmelCase__ = None		,				lowerCAmelCase__ = None		,				lowerCAmelCase__=True		,				)       ->						Union[
          Union[AudioPipelineOutput, ImagePipelineOutput],
          Tuple[List[Image.Image], Tuple[int, List[np.ndarray]]],
      ]:



        '''simple docstring'''




        a__     : List[Any]  =steps or self.get_default_steps()
        self.scheduler.set_timesteps(lowerCAmelCase__							)
        a__     : Tuple  =step_generator or generator
        # For backwards compatibility
        if type(self.unet.config.sample_size							) == int:
          a__     : List[str]  =(self.unet.config.sample_size, self.unet.config.sample_size)
        if noise is None:
          a__     : Optional[Any]  =randn_tensor(
              (
                  batch_size,
                  self.unet.config.in_channels,
                  self.unet.config.sample_size[0],
                  self.unet.config.sample_size[1],
              )		,				generator=lowerCAmelCase__		,				device=self.device		,				)
        a__     : List[str]  =noise
        a__     : Optional[Any]  =None

        if audio_file is not None or raw_audio is not None:
          self.mel.load_audio(lowerCAmelCase__		,				lowerCAmelCase__							)
          a__     : Tuple  =self.mel.audio_slice_to_image(lowerCAmelCase__							)
          a__     : List[Any]  =np.frombuffer(input_image.tobytes()		,				dtype="uint8"							).reshape(
              (input_image.height, input_image.width)							)
          a__     : Optional[Any]  =(input_image / 2_5_5) * 2 - 1
          a__     : Dict  =torch.tensor(input_image[np.newaxis, :, :]		,				dtype=torch.float							).to(self.device							)

          if self.vqvae is not None:
            a__     : str  =self.vqvae.encode(torch.unsqueeze(lowerCAmelCase__		,				0							)							).latent_dist.sample(
                generator=lowerCAmelCase__							)[0]
            a__     : Any  =self.vqvae.config.scaling_factor * input_images

          if start_step > 0:
            a__     : Optional[int]  =self.scheduler.add_noise(lowerCAmelCase__		,				lowerCAmelCase__		,				self.scheduler.timesteps[start_step - 1]							)

          a__     : Tuple  =(
              self.unet.config.sample_size[1] * self.mel.get_sample_rate() / self.mel.x_res / self.mel.hop_length
          )
          a__     : Union[str, Any]  =int(mask_start_secs * pixels_per_second							)
          a__     : List[str]  =int(mask_end_secs * pixels_per_second							)
          a__     : Optional[Any]  =self.scheduler.add_noise(lowerCAmelCase__		,				lowerCAmelCase__		,				torch.tensor(self.scheduler.timesteps[start_step:]							)							)

        for step, t in enumerate(self.progress_bar(self.scheduler.timesteps[start_step:]							)							):
          if isinstance(self.unet		,				lowerCAmelCase__							):
            a__     : List[str]  =self.unet(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__							)["sample"]
          else:
            a__     : Optional[Any]  =self.unet(lowerCAmelCase__		,				lowerCAmelCase__							)["sample"]

          if isinstance(self.scheduler		,				lowerCAmelCase__							):
            a__     : int  =self.scheduler.step(
                model_output=lowerCAmelCase__		,				timestep=lowerCAmelCase__		,				sample=lowerCAmelCase__		,				eta=lowerCAmelCase__		,				generator=lowerCAmelCase__		,				)["prev_sample"]
          else:
            a__     : str  =self.scheduler.step(
                model_output=lowerCAmelCase__		,				timestep=lowerCAmelCase__		,				sample=lowerCAmelCase__		,				generator=lowerCAmelCase__		,				)["prev_sample"]

          if mask is not None:
            if mask_start > 0:
              a__     : List[Any]  =mask[:, step, :, :mask_start]
            if mask_end > 0:
              a__     : Union[str, Any]  =mask[:, step, :, -mask_end:]

        if self.vqvae is not None:
          # 0.18215 was scaling factor used in training to ensure unit variance
          a__     : Any  =1 / self.vqvae.config.scaling_factor * images
          a__     : str  =self.vqvae.decode(lowerCAmelCase__							)["sample"]

        a__     : str  =(images / 2 + 0.5).clamp(0		,				1							)
        a__     : int  =images.cpu().permute(0		,				2		,				3		,				1							).numpy()
        a__     : List[Any]  =(images * 2_5_5).round().astype("uint8"							)
        a__     : Dict  =list(
            (Image.fromarray(_[:, :, 0]							) for _ in images)
            if images.shape[3] == 1
            else (Image.fromarray(lowerCAmelCase__		,				mode="RGB"							).convert("L"							) for _ in images)							)

        a__     : str  =[self.mel.image_to_audio(lowerCAmelCase__							) for _ in images]
        if not return_dict:
          return images, (self.mel.get_sample_rate(), audios)

        return BaseOutput(**AudioPipelineOutput(np.array(lowerCAmelCase__							)[:, np.newaxis, :]							)		,				**ImagePipelineOutput(lowerCAmelCase__							)							)







      @torch.no_grad()
      def        _lowercase  (   self		,				lowerCAmelCase__		,				lowerCAmelCase__ = 5_0							)       ->						np.ndarray:



        '''simple docstring'''




        assert isinstance(self.scheduler		,				lowerCAmelCase__							)
        self.scheduler.set_timesteps(lowerCAmelCase__							)
        a__     : Union[str, Any]  =np.array(
            [np.frombuffer(image.tobytes()		,				dtype="uint8"							).reshape((1, image.height, image.width)							) for image in images]							)
        a__     : Tuple  =(sample / 2_5_5) * 2 - 1
        a__     : List[Any]  =torch.Tensor(lowerCAmelCase__							).to(self.device							)

        for t in self.progress_bar(torch.flip(self.scheduler.timesteps		,				(0,)							)							):
          a__     : str  =t - self.scheduler.config.num_train_timesteps // self.scheduler.num_inference_steps
          a__     : Dict  =self.scheduler.alphas_cumprod[t]
          a__     : Optional[Any]  =(
              self.scheduler.alphas_cumprod[prev_timestep]
              if prev_timestep >= 0
              else self.scheduler.final_alpha_cumprod
          )
          a__     : Optional[Any]  =1 - alpha_prod_t
          a__     : str  =self.unet(lowerCAmelCase__		,				lowerCAmelCase__							)["sample"]
          a__     : Optional[Any]  =(1 - alpha_prod_t_prev) ** 0.5 * model_output
          a__     : List[str]  =(sample - pred_sample_direction) * alpha_prod_t_prev ** (-0.5)
          a__     : Optional[Any]  =sample * alpha_prod_t ** 0.5 + beta_prod_t ** 0.5 * model_output

        return sample







      @staticmethod
      def        _lowercase  (   lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__							)       ->						torch.Tensor:



        '''simple docstring'''




        a__     : Any  =acos(torch.dot(torch.flatten(lowerCAmelCase__							)		,				torch.flatten(lowerCAmelCase__							)							) / torch.norm(lowerCAmelCase__							) / torch.norm(lowerCAmelCase__							)							)
        return sin((1 - alpha) * theta							) * xa / sin(lowerCAmelCase__							) + sin(alpha * theta							) * xa / sin(lowerCAmelCase__							)






