





from __future__ import annotations

import unittest

from transformers import LEDConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
      import tensorflow as tf

      from transformers import TFLEDForConditionalGeneration, TFLEDModel

@require_tf
class       snake_case					:
  lowercase_			=     LEDConfig
  lowercase_			=     {}
  lowercase_			=     'gelu'




  def __init__(      self     :	Union[str, Any]     , a_     :	Optional[Any]     , a_     :	str=13     , a_     :	Any=7     , a_     :	Union[str, Any]=True     , a_     :	Dict=False     , a_     :	Any=99     , a_     :	str=32     , a_     :	Union[str, Any]=2     , a_     :	Optional[Any]=4     , a_     :	List[str]=37     , a_     :	Any=0.1     , a_     :	Dict=0.1     , a_     :	Any=20     , a_     :	List[str]=2     , a_     :	Any=1     , a_     :	int=0     , a_     :	Optional[int]=4     , )->       Optional[int]:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__				:				List[str]			=		parent
       SCREAMING_SNAKE_CASE__				:				Dict			=		batch_size
       SCREAMING_SNAKE_CASE__				:				Dict			=		seq_length
       SCREAMING_SNAKE_CASE__				:				Optional[int]			=		is_training
       SCREAMING_SNAKE_CASE__				:				str			=		use_labels
       SCREAMING_SNAKE_CASE__				:				List[str]			=		vocab_size
       SCREAMING_SNAKE_CASE__				:				List[Any]			=		hidden_size
       SCREAMING_SNAKE_CASE__				:				int			=		num_hidden_layers
       SCREAMING_SNAKE_CASE__				:				Any			=		num_attention_heads
       SCREAMING_SNAKE_CASE__				:				Union[str, Any]			=		intermediate_size

       SCREAMING_SNAKE_CASE__				:				List[Any]			=		hidden_dropout_prob
       SCREAMING_SNAKE_CASE__				:				Optional[int]			=		attention_probs_dropout_prob
       SCREAMING_SNAKE_CASE__				:				str			=		max_position_embeddings
       SCREAMING_SNAKE_CASE__				:				Tuple			=		eos_token_id
       SCREAMING_SNAKE_CASE__				:				Tuple			=		pad_token_id
       SCREAMING_SNAKE_CASE__				:				str			=		bos_token_id
       SCREAMING_SNAKE_CASE__				:				Optional[Any]			=		attention_window

       # `ModelTesterMixin.test_attention_outputs` is expecting attention tensors to be of size
       # [num_attention_heads, encoder_seq_length, encoder_key_length], but TFLongformerSelfAttention
       # returns attention of shape [num_attention_heads, encoder_seq_length, self.attention_window + 1]
       # because its local attention only attends to `self.attention_window` and one before and one after
       SCREAMING_SNAKE_CASE__				:				Dict			=		self.attention_window + 2

       # because of padding `encoder_seq_length`, is different from `seq_length`. Relevant for
       # the `test_attention_outputs` and `test_hidden_states_output` tests
       SCREAMING_SNAKE_CASE__				:				Dict			=		(
           self.seq_length + (self.attention_window - self.seq_length % self.attention_window) % self.attention_window
       )




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




       """simple docstring"""
       SCREAMING_SNAKE_CASE__				:				Optional[int]			=		ids_tensor([self.batch_size, self.seq_length - 1]     , self.vocab_size				)
       SCREAMING_SNAKE_CASE__				:				Any			=		tf.expand_dims(tf.constant([self.eos_token_id] * self.batch_size				)     , 1				)
       SCREAMING_SNAKE_CASE__				:				List[Any]			=		tf.concat([input_ids, eos_tensor]     , axis=1				)

       SCREAMING_SNAKE_CASE__				:				Dict			=		ids_tensor([self.batch_size, self.seq_length]     , self.vocab_size				)

       SCREAMING_SNAKE_CASE__				:				Dict			=		self.config_cls(
           vocab_size=self.vocab_size     , d_model=self.hidden_size     , encoder_layers=self.num_hidden_layers     , decoder_layers=self.num_hidden_layers     , encoder_attention_heads=self.num_attention_heads     , decoder_attention_heads=self.num_attention_heads     , encoder_ffn_dim=self.intermediate_size     , decoder_ffn_dim=self.intermediate_size     , dropout=self.hidden_dropout_prob     , attention_dropout=self.attention_probs_dropout_prob     , max_position_embeddings=self.max_position_embeddings     , eos_token_ids=[2]     , bos_token_id=self.bos_token_id     , pad_token_id=self.pad_token_id     , decoder_start_token_id=self.pad_token_id     , attention_window=self.attention_window     , **self.config_updates     , )
       SCREAMING_SNAKE_CASE__				:				str			=		prepare_led_inputs_dict(_UpperCAmelCase     , _UpperCAmelCase     , _UpperCAmelCase				)
       SCREAMING_SNAKE_CASE__				:				Dict			=		tf.concat(
           [tf.zeros_like(_UpperCAmelCase				)[:, :-1], tf.ones_like(_UpperCAmelCase				)[:, -1:]]     , axis=-1     , )
       SCREAMING_SNAKE_CASE__				:				Optional[int]			=		global_attention_mask
       return config, inputs_dict




  def 	__lowercase(      self     :	Optional[int]     , a_     :	int     , a_     :	Any				)->       str:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__				:				str			=		TFLEDModel(config=_UpperCAmelCase				).get_decoder()
       SCREAMING_SNAKE_CASE__				:				Union[str, Any]			=		inputs_dict['input_ids']

       SCREAMING_SNAKE_CASE__				:				List[str]			=		input_ids[:1, :]
       SCREAMING_SNAKE_CASE__				:				int			=		inputs_dict['attention_mask'][:1, :]
       SCREAMING_SNAKE_CASE__				:				Union[str, Any]			=		1

       # first forward pass
       SCREAMING_SNAKE_CASE__				:				Any			=		model(_UpperCAmelCase     , attention_mask=_UpperCAmelCase     , use_cache=_UpperCAmelCase				)

       SCREAMING_SNAKE_CASE__			,							SCREAMING_SNAKE_CASE__				:				int			=		outputs.to_tuple()

       # create hypothetical next token and extent to next_input_ids
       SCREAMING_SNAKE_CASE__				:				List[Any]			=		ids_tensor((self.batch_size, 3)     , config.vocab_size				)
       SCREAMING_SNAKE_CASE__				:				Union[str, Any]			=		tf.cast(ids_tensor((self.batch_size, 3)     , 2				)     , tf.inta				)

       # append to next input_ids and
       SCREAMING_SNAKE_CASE__				:				str			=		tf.concat([input_ids, next_tokens]     , axis=-1				)
       SCREAMING_SNAKE_CASE__				:				int			=		tf.concat([attention_mask, next_attn_mask]     , axis=-1				)

       SCREAMING_SNAKE_CASE__				:				str			=		model(_UpperCAmelCase     , attention_mask=_UpperCAmelCase				)[0]
       SCREAMING_SNAKE_CASE__				:				Union[str, Any]			=		model(_UpperCAmelCase     , attention_mask=_UpperCAmelCase     , past_key_values=_UpperCAmelCase				)[0]

       self.parent.assertEqual(next_tokens.shape[1]     , output_from_past.shape[1]				)

       # select random slice
       SCREAMING_SNAKE_CASE__				:				Optional[Any]			=		int(ids_tensor((1,)     , output_from_past.shape[-1]				)				)
       SCREAMING_SNAKE_CASE__				:				List[Any]			=		output_from_no_past[:, -3:, random_slice_idx]
       SCREAMING_SNAKE_CASE__				:				List[Any]			=		output_from_past[:, :, random_slice_idx]

       # test that outputs are equal for slice
       tf.debugging.assert_near(_UpperCAmelCase     , _UpperCAmelCase     , rtol=1e-3				)







def     _a				(      lowercase__  :			List[Any]     ,  lowercase__  :			Optional[Any]     ,  lowercase__  :			Any     ,  lowercase__  :			Optional[int]=None     ,  lowercase__  :			Tuple=None     ,  lowercase__  :			str=None     ,  lowercase__  :			Tuple=None     ,  ):







     '''simple docstring'''


     if attention_mask is None:
          SCREAMING_SNAKE_CASE__				:				Tuple			=		tf.cast(tf.math.not_equal(lowerCAmelCase__     ,  config.pad_token_id )     ,  tf.inta )
     if decoder_attention_mask is None:
          SCREAMING_SNAKE_CASE__				:				Dict			=		tf.concat(
              [
                  tf.ones(decoder_input_ids[:, :1].shape     ,  dtype=tf.inta ),
                  tf.cast(tf.math.not_equal(decoder_input_ids[:, 1:]     ,  config.pad_token_id )     ,  tf.inta ),
              ]     ,  axis=-1     ,  )
     if head_mask is None:
          SCREAMING_SNAKE_CASE__				:				List[Any]			=		tf.ones((config.encoder_layers, config.encoder_attention_heads) )
     if decoder_head_mask is None:
          SCREAMING_SNAKE_CASE__				:				str			=		tf.ones((config.decoder_layers, config.decoder_attention_heads) )
     return {
         "input_ids": input_ids,
         "attention_mask": attention_mask,
         "decoder_input_ids": decoder_input_ids,
         "decoder_attention_mask": decoder_attention_mask,
         "head_mask": head_mask,
         "decoder_head_mask": decoder_head_mask,
     }

@require_tf
class       snake_case					(      UpperCamelCase_   ,						UpperCamelCase_   ,						unittest.TestCase						):
  lowercase_			=     (TFLEDForConditionalGeneration, TFLEDModel) if is_tf_available() else ()
  lowercase_			=     (TFLEDForConditionalGeneration,) if is_tf_available() else ()
  lowercase_			=     (
      {
          'conversational': TFLEDForConditionalGeneration,
          'feature-extraction': TFLEDModel,
          'summarization': TFLEDForConditionalGeneration,
          'text2text-generation': TFLEDForConditionalGeneration,
          'translation': TFLEDForConditionalGeneration,
      }
      if is_tf_available()
      else {}
  )
  lowercase_			=     True
  lowercase_			=     False
  lowercase_			=     False
  lowercase_			=     False




  def 	__lowercase(      self     :	str				)->       Optional[Any]:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__				:				List[str]			=		TFLEDModelTester(self				)
       SCREAMING_SNAKE_CASE__				:				Tuple			=		ConfigTester(self     , config_class=_UpperCAmelCase				)




  def 	__lowercase(      self     :	Tuple				)->       str:




       """simple docstring"""
       self.config_tester.run_common_tests()




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




       """simple docstring"""
       SCREAMING_SNAKE_CASE__				:				Optional[Any]			=		self.model_tester.prepare_config_and_inputs_for_common()
       self.model_tester.check_decoder_model_past_large_inputs(*_UpperCAmelCase				)




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




       """simple docstring"""
       SCREAMING_SNAKE_CASE__			,							SCREAMING_SNAKE_CASE__				:				Any			=		self.model_tester.prepare_config_and_inputs_for_common()
       SCREAMING_SNAKE_CASE__				:				str			=		tf.zeros_like(inputs_dict['attention_mask']				)
       SCREAMING_SNAKE_CASE__				:				Optional[int]			=		2
       SCREAMING_SNAKE_CASE__				:				Dict			=		tf.where(
           tf.range(self.model_tester.seq_length				)[None, :] < num_global_attn_indices     , 1     , inputs_dict['global_attention_mask']     , )

       SCREAMING_SNAKE_CASE__				:				Union[str, Any]			=		True
       SCREAMING_SNAKE_CASE__				:				Any			=		self.model_tester.seq_length
       SCREAMING_SNAKE_CASE__				:				Optional[Any]			=		self.model_tester.encoder_seq_length

       def check_decoder_attentions_output(a_     :	Optional[int]				):
            SCREAMING_SNAKE_CASE__				:				Tuple			=		outputs.decoder_attentions
            self.assertEqual(len(_UpperCAmelCase				)     , self.model_tester.num_hidden_layers				)
            self.assertListEqual(
                list(decoder_attentions[0].shape[-3:]				)     , [self.model_tester.num_attention_heads, seq_length, seq_length]     , )

       def check_encoder_attentions_output(a_     :	List[str]				):
            SCREAMING_SNAKE_CASE__				:				int			=		[t.numpy() for t in outputs.encoder_attentions]
            SCREAMING_SNAKE_CASE__				:				str			=		[t.numpy() for t in outputs.encoder_global_attentions]
            self.assertEqual(len(_UpperCAmelCase				)     , self.model_tester.num_hidden_layers				)
            self.assertEqual(len(_UpperCAmelCase				)     , self.model_tester.num_hidden_layers				)
            self.assertListEqual(
                list(attentions[0].shape[-3:]				)     , [self.model_tester.num_attention_heads, seq_length, seq_length]     , )
            self.assertListEqual(
                list(global_attentions[0].shape[-3:]				)     , [self.model_tester.num_attention_heads, encoder_seq_length, num_global_attn_indices]     , )

       for model_class in self.all_model_classes:
            SCREAMING_SNAKE_CASE__				:				int			=		True
            SCREAMING_SNAKE_CASE__				:				str			=		False
            SCREAMING_SNAKE_CASE__				:				List[str]			=		False
            SCREAMING_SNAKE_CASE__				:				Any			=		model_class(_UpperCAmelCase				)
            SCREAMING_SNAKE_CASE__				:				Union[str, Any]			=		model(self._prepare_for_class(_UpperCAmelCase     , _UpperCAmelCase				)				)
            SCREAMING_SNAKE_CASE__				:				List[str]			=		len(_UpperCAmelCase				)
            self.assertEqual(config.output_hidden_states     , _UpperCAmelCase				)
            check_encoder_attentions_output(_UpperCAmelCase				)

            if self.is_encoder_decoder:
                 SCREAMING_SNAKE_CASE__				:				Dict			=		model_class(_UpperCAmelCase				)
                 SCREAMING_SNAKE_CASE__				:				Dict			=		model(self._prepare_for_class(_UpperCAmelCase     , _UpperCAmelCase				)				)
                 self.assertEqual(config.output_hidden_states     , _UpperCAmelCase				)
                 check_decoder_attentions_output(_UpperCAmelCase				)

            # Check that output attentions can also be changed via the config
            del inputs_dict["output_attentions"]
            SCREAMING_SNAKE_CASE__				:				Tuple			=		True
            SCREAMING_SNAKE_CASE__				:				Optional[Any]			=		model_class(_UpperCAmelCase				)
            SCREAMING_SNAKE_CASE__				:				List[Any]			=		model(self._prepare_for_class(_UpperCAmelCase     , _UpperCAmelCase				)				)
            self.assertEqual(config.output_hidden_states     , _UpperCAmelCase				)
            check_encoder_attentions_output(_UpperCAmelCase				)

            # Check attention is always last and order is fine
            SCREAMING_SNAKE_CASE__				:				int			=		True
            SCREAMING_SNAKE_CASE__				:				str			=		True
            SCREAMING_SNAKE_CASE__				:				Any			=		model_class(_UpperCAmelCase				)
            SCREAMING_SNAKE_CASE__				:				List[Any]			=		model(self._prepare_for_class(_UpperCAmelCase     , _UpperCAmelCase				)				)

            self.assertEqual(out_len + (2 if self.is_encoder_decoder else 1)     , len(_UpperCAmelCase				)				)
            self.assertEqual(model.config.output_hidden_states     , _UpperCAmelCase				)
            check_encoder_attentions_output(_UpperCAmelCase				)




  @unittest.skip('LED keeps using potentially symbolic tensors in conditionals and breaks tracing.'				)
  def 	__lowercase(      self     :	Dict				)->       Union[str, Any]:




       """simple docstring"""
       pass




  def 	__lowercase(      self     :	Optional[int]				)->       Union[str, Any]:




       """simple docstring"""
       pass







def     _a				(      lowercase__  :			Tuple ):







     '''simple docstring'''


     return tf.constant(lowerCAmelCase__     ,  dtype=tf.intaa )


SCREAMING_SNAKE_CASE__		:					Dict						=					1E-4







@slow
@require_tf
class       snake_case					(      unittest.TestCase						):




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




       """simple docstring"""
       SCREAMING_SNAKE_CASE__				:				Tuple			=		TFLEDForConditionalGeneration.from_pretrained('allenai/led-base-16384'				).led

       # change to intended input here
       SCREAMING_SNAKE_CASE__				:				str			=		_long_tensor([512 * [0, 3_1414, 232, 328, 740, 1140, 1_2695, 69]]				)
       SCREAMING_SNAKE_CASE__				:				int			=		_long_tensor([128 * [0, 3_1414, 232, 328, 740, 1140, 1_2695, 69]]				)
       SCREAMING_SNAKE_CASE__				:				Any			=		prepare_led_inputs_dict(model.config     , _UpperCAmelCase     , _UpperCAmelCase				)
       SCREAMING_SNAKE_CASE__				:				Optional[int]			=		model(**_UpperCAmelCase				)[0]
       SCREAMING_SNAKE_CASE__				:				Dict			=		(1, 1024, 768)
       self.assertEqual(output.shape     , _UpperCAmelCase				)
       # change to expected output here
       SCREAMING_SNAKE_CASE__				:				Optional[int]			=		tf.convert_to_tensor(
           [[2.3050, 2.8279, 0.6531], [-1.8457, -0.1455, -3.5661], [-1.0186, 0.4586, -2.2043]]     , )
       tf.debugging.assert_near(output[:, :3, :3]     , _UpperCAmelCase     , atol=1e-3				)




  def 	__lowercase(      self     :	str				)->       List[Any]:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__				:				Union[str, Any]			=		TFLEDForConditionalGeneration.from_pretrained('allenai/led-base-16384'				)

       # change to intended input here
       SCREAMING_SNAKE_CASE__				:				Optional[Any]			=		_long_tensor([512 * [0, 3_1414, 232, 328, 740, 1140, 1_2695, 69]]				)
       SCREAMING_SNAKE_CASE__				:				Dict			=		_long_tensor([128 * [0, 3_1414, 232, 328, 740, 1140, 1_2695, 69]]				)
       SCREAMING_SNAKE_CASE__				:				Tuple			=		prepare_led_inputs_dict(model.config     , _UpperCAmelCase     , _UpperCAmelCase				)
       SCREAMING_SNAKE_CASE__				:				Tuple			=		model(**_UpperCAmelCase				)[0]
       SCREAMING_SNAKE_CASE__				:				Dict			=		(1, 1024, model.config.vocab_size)
       self.assertEqual(output.shape     , _UpperCAmelCase				)
       # change to expected output here
       SCREAMING_SNAKE_CASE__				:				Union[str, Any]			=		tf.convert_to_tensor(
           [[33.6507, 6.4572, 16.8089], [5.8739, -2.4238, 11.2902], [-3.2139, -4.3149, 4.2783]]     , )
       tf.debugging.assert_near(output[:, :3, :3]     , _UpperCAmelCase     , atol=1e-3     , rtol=1e-3				)




from dataclasses import dataclass
from typing import Tuple

import numpy as np
import torch

@dataclass
class       snake_case					:
  lowercase_			=     42  # [batch_size x 3]
  lowercase_			=     42  # [batch_size x 3]
  lowercase_			=     42  # [batch_size x 3]
  lowercase_			=     42  # [batch_size x 3]
  lowercase_			=     42
  lowercase_			=     42
  lowercase_			=     42
  lowercase_			=     42
  lowercase_			=     42




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




       """simple docstring"""
       assert self.x.shape[0] == self.y.shape[0] == self.z.shape[0] == self.origin.shape[0]
       assert self.x.shape[1] == self.y.shape[1] == self.z.shape[1] == self.origin.shape[1] == 3
       assert len(self.x.shape				) == len(self.y.shape				) == len(self.z.shape				) == len(self.origin.shape				) == 2




  def 	__lowercase(      self     :	Dict				)->       Tuple:




       """simple docstring"""
       return torch.from_numpy(np.array([self.width, self.height]     , dtype=np.floataa				)				)




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




       """simple docstring"""
       return torch.from_numpy(np.array([self.x_fov, self.y_fov]     , dtype=np.floataa				)				)




  def 	__lowercase(      self     :	Tuple				)->       torch.Tensor:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__				:				str			=		torch.arange(self.height * self.width				)
       SCREAMING_SNAKE_CASE__				:				List[Any]			=		torch.stack(
           [
               pixel_indices % self.width,
               torch.div(a_     , self.width     , rounding_mode='trunc'				),
           ]     , axis=1     , )
       return coords




  @property
  def 	__lowercase(      self     :	Any				)->       List[Any]:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__			,							*SCREAMING_SNAKE_CASE__				:				Union[str, Any]			=		self.shape
       SCREAMING_SNAKE_CASE__				:				Tuple			=		int(np.prod(a_				)				)

       SCREAMING_SNAKE_CASE__				:				List[str]			=		self.get_image_coords()
       SCREAMING_SNAKE_CASE__				:				Dict			=		torch.broadcast_to(coords.unsqueeze(0				)     , [batch_size * inner_batch_size, *coords.shape]				)
       SCREAMING_SNAKE_CASE__				:				Any			=		self.get_camera_rays(a_				)

       SCREAMING_SNAKE_CASE__				:				Tuple			=		rays.view(a_     , inner_batch_size * self.height * self.width     , 2     , 3				)

       return rays




  def 	__lowercase(      self     :	Optional[Any]     , a_     :	torch.Tensor				)->       torch.Tensor:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__			,							*SCREAMING_SNAKE_CASE__			,							SCREAMING_SNAKE_CASE__				:				Dict			=		coords.shape
       assert n_coords == 2
       assert batch_size == self.origin.shape[0]

       SCREAMING_SNAKE_CASE__				:				str			=		coords.view(a_     , -1     , 2				)

       SCREAMING_SNAKE_CASE__				:				List[Any]			=		self.resolution()
       SCREAMING_SNAKE_CASE__				:				str			=		self.fov()

       SCREAMING_SNAKE_CASE__				:				Any			=		(flat.float() / (res - 1)) * 2 - 1
       SCREAMING_SNAKE_CASE__				:				Any			=		fracs * torch.tan(fov / 2				)

       SCREAMING_SNAKE_CASE__				:				List[str]			=		fracs.view(a_     , -1     , 2				)
       SCREAMING_SNAKE_CASE__				:				str			=		(
           self.z.view(a_     , 1     , 3				)
           + self.x.view(a_     , 1     , 3				) * fracs[:, :, :1]
           + self.y.view(a_     , 1     , 3				) * fracs[:, :, 1:]
       )
       SCREAMING_SNAKE_CASE__				:				Tuple			=		directions / directions.norm(dim=-1     , keepdim=a_				)
       SCREAMING_SNAKE_CASE__				:				Any			=		torch.stack(
           [
               torch.broadcast_to(self.origin.view(a_     , 1     , 3				)     , [batch_size, directions.shape[1], 3]				),
               directions,
           ]     , dim=2     , )
       return rays.view(a_     , *a_     , 2     , 3				)




  def 	__lowercase(      self     :	Optional[int]     , a_     :	int     , a_     :	int				)->       "DifferentiableProjectiveCamera":




       """simple docstring"""
       assert width * self.height == height * self.width, "The aspect ratio should not change."
       return DifferentiableProjectiveCamera(
           origin=self.origin     , x=self.x     , y=self.y     , z=self.z     , width=a_     , height=a_     , x_fov=self.x_fov     , y_fov=self.y_fov     , )







def     _a				(      lowercase__  :			int ):







     '''simple docstring'''


     SCREAMING_SNAKE_CASE__				:				Any			=		[]
     SCREAMING_SNAKE_CASE__				:				List[Any]			=		[]
     SCREAMING_SNAKE_CASE__				:				Optional[int]			=		[]
     SCREAMING_SNAKE_CASE__				:				str			=		[]
     for theta in np.linspace(0     ,  2 * np.pi     ,  num=20 ):
          SCREAMING_SNAKE_CASE__				:				Optional[Any]			=		np.array([np.sin(lowercase__ ), np.cos(lowercase__ ), -0.5] )
          z /= np.sqrt(np.sum(z**2 ) )
          SCREAMING_SNAKE_CASE__				:				Tuple			=		-z * 4
          SCREAMING_SNAKE_CASE__				:				Optional[Any]			=		np.array([np.cos(lowercase__ ), -np.sin(lowercase__ ), 0.0] )
          SCREAMING_SNAKE_CASE__				:				Optional[int]			=		np.cross(lowercase__     ,  lowercase__ )
          origins.append(lowercase__ )
          xs.append(lowercase__ )
          ys.append(lowercase__ )
          zs.append(lowercase__ )
     return DifferentiableProjectiveCamera(
         origin=torch.from_numpy(np.stack(lowercase__     ,  axis=0 ) ).float()     ,  x=torch.from_numpy(np.stack(lowercase__     ,  axis=0 ) ).float()     ,  y=torch.from_numpy(np.stack(lowercase__     ,  axis=0 ) ).float()     ,  z=torch.from_numpy(np.stack(lowercase__     ,  axis=0 ) ).float()     ,  width=lowercase__     ,  height=lowercase__     ,  x_fov=0.7     ,  y_fov=0.7     ,  shape=(1, len(lowercase__ ))     ,  )



