





"""simple docstring"""





from __future__ import annotations

from math import pi

# Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of
# Pi and the function
SCREAMING_SNAKE_CASE__   =  1.0_54_57_18_17e-34  # unit of ℏ : J * s

SCREAMING_SNAKE_CASE__   =  3e8  # unit of c : m * s^-1


def      UpperCAmelCase__				(    SCREAMING_SNAKE_CASE	:		float				,		SCREAMING_SNAKE_CASE	:		float				,		SCREAMING_SNAKE_CASE	:		float     ):







      '''simple docstring'''




      if (force, area, distance).count(0     ) != 1:
            raise ValueError("""One and only one argument must be 0"""     )
      if force < 0:
            raise ValueError("""Magnitude of force can not be negative"""     )
      if distance < 0:
            raise ValueError("""Distance can not be negative"""     )
      if area < 0:
            raise ValueError("""Area can not be negative"""     )
      if force == 0:
            lowerCAmelCase    		=			(REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2 * area) / (
                2_40 * (distance) ** 4
            )
            return {"force": force}
      elif area == 0:
            lowerCAmelCase    		=			(2_40 * force * (distance) ** 4) / (
                REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2
            )
            return {"area": area}
      elif distance == 0:
            lowerCAmelCase    		=			(
                (REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2 * area) / (2_40 * force)
            ) ** (1 / 4)
            return {"distance": distance}
      raise ValueError("""One and only one argument must be 0"""     )


# Run doctest
if __name__ == "__main__":
       import doctest

       doctest.testmod()













"""simple docstring"""





import unittest

from transformers import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision, slow, torch_device


if is_torch_available():
       import torch

       from transformers import AutoModelForImageClassification

if is_vision_available():
       from transformers import AutoImageProcessor

@require_torch
@require_vision
class 						lowercase   (   unittest.TestCase   ):





      @slow
      def        _snake_case     (			self					)						->	Any:
            lowerCAmelCase    		=			AutoImageProcessor.from_pretrained("""microsoft/dit-base-finetuned-rvlcdip"""					)
            lowerCAmelCase    		=			AutoModelForImageClassification.from_pretrained("""microsoft/dit-base-finetuned-rvlcdip"""					)
            model.to(lowercase					)

            from datasets import load_dataset

            lowerCAmelCase    		=			load_dataset("""nielsr/rvlcdip-demo"""					)

            lowerCAmelCase    		=			dataset["""train"""][0]["""image"""].convert("""RGB"""					)

            lowerCAmelCase    		=			image_processor(lowercase ,		return_tensors="""pt"""					).to(lowercase					)

            # forward pass
            with torch.no_grad():
                  lowerCAmelCase    		=			model(**lowercase					)
                  lowerCAmelCase    		=			outputs.logits

            lowerCAmelCase    		=			torch.Size((1, 16)					)
            self.assertEqual(logits.shape ,		lowercase					)

            lowerCAmelCase    		=			torch.tensor(
                [-0.4_158, -0.4_092, -0.4_347] ,		device=lowercase ,		dtype=torch.float ,		)
            self.assertTrue(torch.allclose(logits[0, :3] ,		lowercase ,		atol=1e-4					)					)






