






"""simple docstring"""






import inspect
import unittest

import numpy as np

from tests.test_modeling_common import floats_tensor
from transformers import MaskaFormerConfig, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch

    from transformers import MaskaFormerForUniversalSegmentation, MaskaFormerModel

    if is_vision_available():
        from transformers import MaskaFormerImageProcessor

if is_vision_available():
    from PIL import Image
class     __lowerCAmelCase :







  '''simple docstring'''


  def __init__(   self:		List[Any]					,      UpperCamelCase_:		Optional[int]					,      UpperCamelCase_:		Any=2					,      UpperCamelCase_:		Tuple=True					,      UpperCamelCase_:		Optional[Any]=False					,      UpperCamelCase_:		Any=10					,      UpperCamelCase_:		Dict=3					,      UpperCamelCase_:		List[Any]=32 * 8					,      UpperCamelCase_:		Dict=32 * 8					,      UpperCamelCase_:		Dict=4					,      UpperCamelCase_:		Tuple=64					,      ):
     UpperCamelCase_			     =parent
     UpperCamelCase_			     =batch_size
     UpperCamelCase_			     =is_training
     UpperCamelCase_			     =use_auxiliary_loss
     UpperCamelCase_			     =num_queries
     UpperCamelCase_			     =num_channels
     UpperCamelCase_			     =min_size
     UpperCamelCase_			     =max_size
     UpperCamelCase_			     =num_labels
     UpperCamelCase_			     =hidden_dim
     UpperCamelCase_			     =hidden_dim
  def        UpperCamelCase__ (   self:		Optional[int]       ):
     UpperCamelCase_			     =floats_tensor([self.batch_size, self.num_channels, self.min_size, self.max_size]       ).to(
         UpperCamelCase_       )

     UpperCamelCase_			     =torch.ones([self.batch_size, self.min_size, self.max_size]					,      device=UpperCamelCase_       )

     UpperCamelCase_			     =(
         torch.rand([self.batch_size, self.num_labels, self.min_size, self.max_size]					,      device=UpperCamelCase_       ) > 0.5
     ).float()
     UpperCamelCase_			     =(torch.rand((self.batch_size, self.num_labels)					,      device=UpperCamelCase_       ) > 0.5).long()

     UpperCamelCase_			     =self.get_config()
     return config, pixel_values, pixel_mask, mask_labels, class_labels
  def        UpperCamelCase__ (   self:		Tuple       ):
     UpperCamelCase_			     =MaskaFormerConfig(
         hidden_size=self.hidden_dim					,      )
     UpperCamelCase_			     =self.num_queries
     UpperCamelCase_			     =self.num_labels

     UpperCamelCase_			     =[1, 1, 1, 1]
     UpperCamelCase_			     =self.num_channels

     UpperCamelCase_			     =64
     UpperCamelCase_			     =128
     UpperCamelCase_			     =self.hidden_dim
     UpperCamelCase_			     =self.hidden_dim
     UpperCamelCase_			     =self.hidden_dim
     return config
  def        UpperCamelCase__ (   self:		List[Any]       ):
     UpperCamelCase_			     =self.prepare_config_and_inputs()
     UpperCamelCase_			     ={"""pixel_values""": pixel_values, """pixel_mask""": pixel_mask}
     return config, inputs_dict
  def        UpperCamelCase__ (   self:		Tuple					,      UpperCamelCase_:		Optional[int]					,      UpperCamelCase_:		Union[str, Any]       ):
     UpperCamelCase_			     =output.encoder_hidden_states
     UpperCamelCase_			     =output.pixel_decoder_hidden_states
     UpperCamelCase_			     =output.transformer_decoder_hidden_states

     self.parent.assertTrue(len(UpperCamelCase_       )					,      len(config.backbone_config.depths       )       )
     self.parent.assertTrue(len(UpperCamelCase_       )					,      len(config.backbone_config.depths       )       )
     self.parent.assertTrue(len(UpperCamelCase_       )					,      config.decoder_layers       )
  def        UpperCamelCase__ (   self:		Optional[int]					,      UpperCamelCase_:		Union[str, Any]					,      UpperCamelCase_:		List[str]					,      UpperCamelCase_:		Any					,      UpperCamelCase_:		str=False       ):
     with torch.no_grad():
        UpperCamelCase_			     =MaskaFormerModel(config=UpperCamelCase_       )
        model.to(UpperCamelCase_       )
        model.eval()

        UpperCamelCase_			     =model(pixel_values=UpperCamelCase_					,      pixel_mask=UpperCamelCase_       )
        UpperCamelCase_			     =model(UpperCamelCase_					,      output_hidden_states=UpperCamelCase_       )

     self.parent.assertEqual(
         output.transformer_decoder_last_hidden_state.shape					,      (self.batch_size, self.num_queries, self.hidden_dim)					,      )
     # let's ensure the other two hidden state exists
     self.parent.assertTrue(output.pixel_decoder_last_hidden_state is not None       )
     self.parent.assertTrue(output.encoder_last_hidden_state is not None       )

     if output_hidden_states:
        self.check_output_hidden_state(UpperCamelCase_					,      UpperCamelCase_       )





  def        UpperCamelCase__ (   self:		Optional[int]					,      UpperCamelCase_:		Optional[int]					,      UpperCamelCase_:		str					,      UpperCamelCase_:		Any					,      UpperCamelCase_:		List[str]					,      UpperCamelCase_:		int       ):
     UpperCamelCase_			     =MaskaFormerForUniversalSegmentation(config=UpperCamelCase_       )
     model.to(UpperCamelCase_       )
     model.eval()

     def comm_check_on_output(UpperCamelCase_:		Optional[int]       ):
        # let's still check that all the required stuff is there
        self.parent.assertTrue(result.transformer_decoder_last_hidden_state is not None       )
        self.parent.assertTrue(result.pixel_decoder_last_hidden_state is not None       )
        self.parent.assertTrue(result.encoder_last_hidden_state is not None       )
        # okay, now we need to check the logits shape
        # due to the encoder compression, masks have a //4 spatial size
        self.parent.assertEqual(
            result.masks_queries_logits.shape					,      (self.batch_size, self.num_queries, self.min_size // 4, self.max_size // 4)					,      )
        # + 1 for null class
        self.parent.assertEqual(
            result.class_queries_logits.shape					,      (self.batch_size, self.num_queries, self.num_labels + 1)       )

     with torch.no_grad():
        UpperCamelCase_			     =model(pixel_values=UpperCamelCase_					,      pixel_mask=UpperCamelCase_       )
        UpperCamelCase_			     =model(UpperCamelCase_       )

        comm_check_on_output(UpperCamelCase_       )

        UpperCamelCase_			     =model(
            pixel_values=UpperCamelCase_					,      pixel_mask=UpperCamelCase_					,      mask_labels=UpperCamelCase_					,      class_labels=UpperCamelCase_       )

     comm_check_on_output(UpperCamelCase_       )

     self.parent.assertTrue(result.loss is not None       )
     self.parent.assertEqual(result.loss.shape					,      torch.Size([1]       )       )




@require_torch
class     __lowerCAmelCase (      A_							, A_							, unittest.TestCase							):







  '''simple docstring'''


  __lowerCamelCase							:     Union[str, Any]  						=      (MaskaFormerModel, MaskaFormerForUniversalSegmentation) if is_torch_available() else ()
  __lowerCamelCase							:     Optional[int]  						=      {"feature-extraction": MaskaFormerModel} if is_torch_available() else {}

  __lowerCamelCase							:     List[str]  						=      False
  __lowerCamelCase							:     int  						=      False
  __lowerCamelCase							:     Tuple  						=      False
  __lowerCamelCase							:     str  						=      False
  def        UpperCamelCase__ (   self:		int       ):
     UpperCamelCase_			     =MaskaFormerModelTester(self       )
     UpperCamelCase_			     =ConfigTester(self					,      config_class=UpperCamelCase_					,      has_text_modality=UpperCamelCase_       )
  def        UpperCamelCase__ (   self:		Any       ):
     self.config_tester.run_common_tests()
  def        UpperCamelCase__ (   self:		List[Any]       ):
     UpperCamelCase_			     =self.model_tester.prepare_config_and_inputs_for_common()
     self.model_tester.create_and_check_maskaformer_model(UpperCamelCase_					,      **UpperCamelCase_					,      output_hidden_states=UpperCamelCase_       )
  def        UpperCamelCase__ (   self:		Dict       ):
     UpperCamelCase_			     =self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_maskaformer_instance_segmentation_head_model(*UpperCamelCase_       )
  @unittest.skip(reason="Mask2Former does not use inputs_embeds"       )
  def        UpperCamelCase__ (   self:		List[str]       ):
     pass
  @unittest.skip(reason="Mask2Former does not have a get_input_embeddings method"       )
  def        UpperCamelCase__ (   self:		Any       ):
     pass
  @unittest.skip(reason="Mask2Former is not a generative model"       )
  def        UpperCamelCase__ (   self:		int       ):
     pass
  @unittest.skip(reason="Mask2Former does not use token embeddings"       )
  def        UpperCamelCase__ (   self:		Optional[Any]       ):
     pass
  @require_torch_multi_gpu
  @unittest.skip(
      reason="Mask2Former has some layers using `add_module` which doesn't work well with `nn.DataParallel`"       )
  def        UpperCamelCase__ (   self:		int       ):
     pass
  @unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."       )
  def        UpperCamelCase__ (   self:		Tuple       ):
     pass
  def        UpperCamelCase__ (   self:		Tuple       ):
     UpperCamelCase_			     =self.model_tester.prepare_config_and_inputs_for_common()

     for model_class in self.all_model_classes:
        UpperCamelCase_			     =model_class(UpperCamelCase_       )
        UpperCamelCase_			     =inspect.signature(model.forward       )
        # signature.parameters is an OrderedDict => so arg_names order is deterministic
        UpperCamelCase_			     =[*signature.parameters.keys()]

        UpperCamelCase_			     =["""pixel_values"""]
        self.assertListEqual(arg_names[:1]					,      UpperCamelCase_       )
  @slow
  def        UpperCamelCase__ (   self:		Optional[int]       ):
     for model_name in ["facebook/mask2former-swin-small-coco-instance"]:
        UpperCamelCase_			     =MaskaFormerModel.from_pretrained(UpperCamelCase_       )
        self.assertIsNotNone(UpperCamelCase_       )
  def        UpperCamelCase__ (   self:		Optional[Any]       ):
     UpperCamelCase_			     =(self.model_tester.min_size,) * 2
     UpperCamelCase_			     ={
         """pixel_values""": torch.randn((2, 3, *size)					,      device=UpperCamelCase_       ),
         """mask_labels""": torch.randn((2, 10, *size)					,      device=UpperCamelCase_       ),
         """class_labels""": torch.zeros(2					,      10					,      device=UpperCamelCase_       ).long(),
     }
     UpperCamelCase_			     =self.model_tester.get_config()

     UpperCamelCase_			     =MaskaFormerForUniversalSegmentation(UpperCamelCase_       ).to(UpperCamelCase_       )
     UpperCamelCase_			     =model(**UpperCamelCase_       )
     self.assertTrue(outputs.loss is not None       )
  def        UpperCamelCase__ (   self:		str       ):
     UpperCamelCase_			     =self.model_tester.prepare_config_and_inputs_for_common()
     self.model_tester.create_and_check_maskaformer_model(UpperCamelCase_					,      **UpperCamelCase_					,      output_hidden_states=UpperCamelCase_       )
  def        UpperCamelCase__ (   self:		Optional[Any]       ):
     UpperCamelCase_			     =self.model_tester.prepare_config_and_inputs_for_common()

     for model_class in self.all_model_classes:
        UpperCamelCase_			     =model_class(UpperCamelCase_       ).to(UpperCamelCase_       )
        UpperCamelCase_			     =model(**UpperCamelCase_					,      output_attentions=UpperCamelCase_       )
        self.assertTrue(outputs.attentions is not None       )
  def        UpperCamelCase__ (   self:		Union[str, Any]       ):
     if not self.model_tester.is_training:
        return

     UpperCamelCase_			     =self.all_model_classes[1]
     UpperCamelCase_			     =self.model_tester.prepare_config_and_inputs()

     UpperCamelCase_			     =model_class(UpperCamelCase_       )
     model.to(UpperCamelCase_       )
     model.train()

     UpperCamelCase_			     =model(UpperCamelCase_					,      mask_labels=UpperCamelCase_					,      class_labels=UpperCamelCase_       ).loss
     loss.backward()





  def        UpperCamelCase__ (   self:		str       ):
     UpperCamelCase_			     =self.all_model_classes[1]
     UpperCamelCase_			     =self.model_tester.prepare_config_and_inputs()
     UpperCamelCase_			     =True
     UpperCamelCase_			     =True

     UpperCamelCase_			     =model_class(UpperCamelCase_       ).to(UpperCamelCase_       )
     model.train()

     UpperCamelCase_			     =model(UpperCamelCase_					,      mask_labels=UpperCamelCase_					,      class_labels=UpperCamelCase_       )

     UpperCamelCase_			     =outputs.encoder_hidden_states[0]
     encoder_hidden_states.retain_grad()

     UpperCamelCase_			     =outputs.pixel_decoder_hidden_states[0]
     pixel_decoder_hidden_states.retain_grad()

     UpperCamelCase_			     =outputs.transformer_decoder_hidden_states[0]
     transformer_decoder_hidden_states.retain_grad()

     UpperCamelCase_			     =outputs.attentions[0]
     attentions.retain_grad()

     outputs.loss.backward(retain_graph=UpperCamelCase_       )

     self.assertIsNotNone(encoder_hidden_states.grad       )
     self.assertIsNotNone(pixel_decoder_hidden_states.grad       )
     self.assertIsNotNone(transformer_decoder_hidden_states.grad       )
     self.assertIsNotNone(attentions.grad       )




A_      	=     1e-4




def     _UpperCamelCase      (	):
   UpperCamelCase_			     =Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"      )
   return image
@require_vision
@slow
class     __lowerCAmelCase (      unittest.TestCase							):







  '''simple docstring'''


  @cached_property
  def        UpperCamelCase__ (   self:		List[Any]       ):
     return "facebook/mask2former-swin-small-coco-instance"
  @cached_property
  def        UpperCamelCase__ (   self:		int       ):
     return MaskaFormerImageProcessor.from_pretrained(self.model_checkpoints       ) if is_vision_available() else None
  def        UpperCamelCase__ (   self:		Tuple       ):
     UpperCamelCase_			     =MaskaFormerModel.from_pretrained(self.model_checkpoints       ).to(UpperCamelCase_       )
     UpperCamelCase_			     =self.default_image_processor
     UpperCamelCase_			     =prepare_img()
     UpperCamelCase_			     =image_processor(UpperCamelCase_					,      return_tensors="pt"       ).to(UpperCamelCase_       )
     UpperCamelCase_			     =inputs["""pixel_values"""].shape
     # check size is divisible by 32
     self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0       )
     # check size
     self.assertEqual(UpperCamelCase_					,      (1, 3, 384, 384)       )

     with torch.no_grad():
        UpperCamelCase_			     =model(**UpperCamelCase_       )

     UpperCamelCase_			     =torch.tensor(
         [[-0.2790, -1.0717, -1.1668], [-0.5128, -0.3128, -0.4987], [-0.5832, 0.1971, -0.0197]]       ).to(UpperCamelCase_       )
     self.assertTrue(
         torch.allclose(
             outputs.encoder_last_hidden_state[0, 0, :3, :3]					,      UpperCamelCase_					,      atol=UpperCamelCase_       )       )

     UpperCamelCase_			     =torch.tensor(
         [[0.8973, 1.1847, 1.1776], [1.1934, 1.5040, 1.5128], [1.1153, 1.4486, 1.4951]]       ).to(UpperCamelCase_       )
     self.assertTrue(
         torch.allclose(
             outputs.pixel_decoder_last_hidden_state[0, 0, :3, :3]					,      UpperCamelCase_					,      atol=UpperCamelCase_       )       )

     UpperCamelCase_			     =torch.tensor(
         [[2.1152, 1.7000, -0.8603], [1.5808, 1.8004, -0.9353], [1.6043, 1.7495, -0.5999]]       ).to(UpperCamelCase_       )
     self.assertTrue(
         torch.allclose(
             outputs.transformer_decoder_last_hidden_state[0, :3, :3]					,      UpperCamelCase_					,      atol=UpperCamelCase_       )       )
  def        UpperCamelCase__ (   self:		Optional[int]       ):
     UpperCamelCase_			     =MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints       ).to(UpperCamelCase_       ).eval()
     UpperCamelCase_			     =self.default_image_processor
     UpperCamelCase_			     =prepare_img()
     UpperCamelCase_			     =image_processor(UpperCamelCase_					,      return_tensors="pt"       ).to(UpperCamelCase_       )
     UpperCamelCase_			     =inputs["""pixel_values"""].shape
     # check size is divisible by 32
     self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0       )
     # check size
     self.assertEqual(UpperCamelCase_					,      (1, 3, 384, 384)       )

     with torch.no_grad():
        UpperCamelCase_			     =model(**UpperCamelCase_       )
     # masks_queries_logits
     UpperCamelCase_			     =outputs.masks_queries_logits
     self.assertEqual(
         masks_queries_logits.shape					,      (1, model.config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)       )
     UpperCamelCase_			     =[
         [-8.7839, -9.0056, -8.8121],
         [-7.4104, -7.0313, -6.5401],
         [-6.6105, -6.3427, -6.4675],
     ]
     UpperCamelCase_			     =torch.tensor(UpperCamelCase_       ).to(UpperCamelCase_       )
     self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]					,      UpperCamelCase_					,      atol=UpperCamelCase_       )       )
     # class_queries_logits
     UpperCamelCase_			     =outputs.class_queries_logits
     self.assertEqual(class_queries_logits.shape					,      (1, model.config.num_queries, model.config.num_labels + 1)       )
     UpperCamelCase_			     =torch.tensor(
         [
             [1.8324, -8.0835, -4.1922],
             [0.8450, -9.0050, -3.6053],
             [0.3045, -7.7293, -3.0275],
         ]       ).to(UpperCamelCase_       )
     self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]					,      UpperCamelCase_					,      atol=UpperCamelCase_       )       )





  def        UpperCamelCase__ (   self:		str       ):
     UpperCamelCase_			     =MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints       ).to(UpperCamelCase_       ).eval()
     UpperCamelCase_			     =self.default_image_processor

     UpperCamelCase_			     =image_processor(
         [np.zeros((3, 800, 1333)       ), np.zeros((3, 800, 1333)       )]					,      segmentation_maps=[np.zeros((384, 384)       ).astype(np.floataa       ), np.zeros((384, 384)       ).astype(np.floataa       )]					,      return_tensors="pt"					,      )

     UpperCamelCase_			     =inputs["""pixel_values"""].to(UpperCamelCase_       )
     UpperCamelCase_			     =[el.to(UpperCamelCase_       ) for el in inputs["""mask_labels"""]]
     UpperCamelCase_			     =[el.to(UpperCamelCase_       ) for el in inputs["""class_labels"""]]

     with torch.no_grad():
        UpperCamelCase_			     =model(**UpperCamelCase_       )

     self.assertTrue(outputs.loss is not None       )




"""simple docstring"""
import mpmath  # for roots of unity
import numpy as np




class 	lowercase__				:





   def __init__(							self      ,   SCREAMING_SNAKE_CASE=None      ,   SCREAMING_SNAKE_CASE=None)  ->  Tuple:
      # Input as list
      _lowerCamelCase	:					Any   =		list(poly_a or [0])[:]
      _lowerCamelCase	:					Optional[Any]   =		list(poly_b or [0])[:]

      # Remove leading zero coefficients
      while self.polyA[-1] == 0:
         self.polyA.pop()
      _lowerCamelCase	:					int   =		len(self.polyA)

      while self.polyB[-1] == 0:
         self.polyB.pop()
      _lowerCamelCase	:					Union[str, Any]   =		len(self.polyB)

      # Add 0 to make lengths equal a power of 2
      _lowerCamelCase	:					List[Any]   =		int(
          2 ** np.ceil(np.loga(len(self.polyA) + len(self.polyB) - 1)))

      while len(self.polyA) < self.c_max_length:
         self.polyA.append(0)
      while len(self.polyB) < self.c_max_length:
         self.polyB.append(0)
      # A complex root used for the fourier transform
      _lowerCamelCase	:					Optional[Any]   =		complex(mpmath.root(x=1      ,   n=self.c_max_length      ,   k=1))

      # The product
      _lowerCamelCase	:					int   =		self.__multiply()





   def 		UpperCamelCase_  (							self      ,   SCREAMING_SNAKE_CASE)  ->  List[str]:
      _lowerCamelCase	:					Dict   =		[[x] for x in self.polyA] if which == """A""" else [[x] for x in self.polyB]
      # Corner case
      if len(SCREAMING_SNAKE_CASE) <= 1:
         return dft[0]
      #
      _lowerCamelCase	:					str   =		self.c_max_length // 2
      while next_ncol > 0:
         _lowerCamelCase	:					Dict   =		[[] for i in range(SCREAMING_SNAKE_CASE)]
         _lowerCamelCase	:					Tuple   =		self.root**next_ncol

         # First half of next step
         _lowerCamelCase	:					int   =		1
         for j in range(self.c_max_length // (next_ncol * 2)):
            for i in range(SCREAMING_SNAKE_CASE):
               new_dft[i].append(dft[i][j] + current_root * dft[i + next_ncol][j])
            current_root *= root
         # Second half of next step
         _lowerCamelCase	:					Optional[int]   =		1
         for j in range(self.c_max_length // (next_ncol * 2)):
            for i in range(SCREAMING_SNAKE_CASE):
               new_dft[i].append(dft[i][j] - current_root * dft[i + next_ncol][j])
            current_root *= root
         # Update
         _lowerCamelCase	:					Union[str, Any]   =		new_dft
         _lowerCamelCase	:					List[str]   =		next_ncol // 2
      return dft[0]





   def 		UpperCamelCase_  (							self)  ->  str:
      _lowerCamelCase	:					Optional[Any]   =		self.__dft("""A""")
      _lowerCamelCase	:					List[str]   =		self.__dft("""B""")
      _lowerCamelCase	:					List[Any]   =		[[dft_a[i] * dft_b[i] for i in range(self.c_max_length)]]
      del dft_a
      del dft_b

      # Corner Case
      if len(inverce_c[0]) <= 1:
         return inverce_c[0]
      # Inverse DFT
      _lowerCamelCase	:					List[str]   =		2
      while next_ncol <= self.c_max_length:
         _lowerCamelCase	:					Any   =		[[] for i in range(SCREAMING_SNAKE_CASE)]
         _lowerCamelCase	:					List[Any]   =		self.root ** (next_ncol // 2)
         _lowerCamelCase	:					str   =		1
         # First half of next step
         for j in range(self.c_max_length // next_ncol):
            for i in range(next_ncol // 2):
               # Even positions
               new_inverse_c[i].append(
                   (
                       inverce_c[i][j]
                       + inverce_c[i][j + self.c_max_length // next_ncol]
                   )
                   / 2)
               # Odd positions
               new_inverse_c[i + next_ncol // 2].append(
                   (
                       inverce_c[i][j]
                       - inverce_c[i][j + self.c_max_length // next_ncol]
                   )
                   / (2 * current_root))
            current_root *= root
         # Update
         _lowerCamelCase	:					Any   =		new_inverse_c
         next_ncol *= 2
      # Unpack
      _lowerCamelCase	:					Optional[Any]   =		[round(x[0].real      ,   8) + round(x[0].imag      ,   8) * 1j for x in inverce_c]

      # Remove leading 0's
      while inverce_c[-1] == 0:
         inverce_c.pop()
      return inverce_c





   def __str__(							self)  ->  Any:
      _lowerCamelCase	:					Dict   =		"""A = """ + """ + """.join(
          F'{coef}*x^{i}' for coef, i in enumerate(self.polyA[: self.len_A]))
      _lowerCamelCase	:					List[Any]   =		"""B = """ + """ + """.join(
          F'{coef}*x^{i}' for coef, i in enumerate(self.polyB[: self.len_B]))
      _lowerCamelCase	:					int   =		"""A*B = """ + """ + """.join(
          F'{coef}*x^{i}' for coef, i in enumerate(self.product))

      return F'{a}\n{b}\n{c}'


# Unit tests
if __name__ == "__main__":
 import doctest

 doctest.testmod()

